+ 1

How to find the sum of the series which has + and - alternately? For eg: 1-x^2/2+x^3/3-x^4/4+x^5/5...

Sum of series in C++

9th Apr 2018, 1:57 PM
S-Y 007
S-Y 007 - avatar
5 Respuestas
+ 2
Actually the sign can just be (-1)^n where n starts from 0.
9th Apr 2018, 4:07 PM
Emma
+ 1
What Gordie said, and also... Be aware that the order of computation will effect floating point arithmetic errors differently. You will want to experiment to find the least amount of error. What Every Computer Scientist Should Know About Floating Point Arithmetic: http://www.itu.dk/~sestoft/bachelor/IEEE754_article.pdf Also check out: https://stackoverflow.com/questions/6699066/in-which-order-should-floats-be-added-to-get-the-most-precise-result?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
9th Apr 2018, 3:22 PM
Emma
+ 1
Also, did you unintentionally miss out the x ^ 1 term? i.e. was it supposed to be: 1 - x + (x ^ 2 / 2) - (x ^ 3 / 3) etc ?
9th Apr 2018, 3:57 PM
Emma
+ 1
ln(1 + x) = x - (x ^ 2 / 2) + (x ^ 3 / 3) etc Source: http://mathworld.wolfram.com/MaclaurinSeries.html So your series is just: ln(1 + x) - x + 1
9th Apr 2018, 4:10 PM
Emma