69 799
Assignments Done
Successfully Done
In February 2019

Answer to Question #74793 in C++ for Dillon Morris

Question #74793
a. The sum of a series can be computed as sum=x+x^2/2+x^3/3+x^4/4+x^5/5+⋯ ∞<x<∞ stopping when either n terms have been added or when the magnitude of a term in the series is less than 10-6, whichever comes first.
You are required to write a function, sumSeries, which given x, n returns the sum of the series. Use #include <cmath> and the abs function. Do not use the pow function.
Expert's answer
#include <cmath>
double sumSeries(double x, int n)
double sum = 0;
double nominator = 1;
for (int i = 1; i <= n; ++i)
nominator *= x;
double element = nominator/i;
sum += element;
if (std::abs(element) < 0.00001)
return sum;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions