For any x in the range 0 < x and x < 2*pi radians, find the sum of the following infinite series:

c = 1 + 1/2*cos(x) + 1/2*3/4*cos(2*x) + 1/2*3/4*5/6*cos(3*x) + 1/2*3/4*5/6*7/8*cos(4*x) + ...

as a function of the form c = infinite_series2(x).

9 Comments

Show
6 older comments

Raphael Cautain
on 28 Feb 2012

A nice problem. But the singularity provides a domain where a variable loss of precision is observed. Several formulae, which are mathematicaly equivalent and computationaly careful, give distinct results. Guessing the one that was used is the second step of the problem, and maybe the most difficult.

Tim
on 28 Feb 2012

The answer for the third test case seems to be a little off.

@bmtran
on 28 Feb 2012

i agree; my solution on the third and fifth test cases are showing up as incorrect even though I'm using an analytical form of the solution for this problem.

Alfonso Nieto-Castanon
on 29 Feb 2012

agree, I am getting 182.574870487881 and 306.940139754640 for the third and fifth cases, respectively; I guess we are supposed to find a way to better approximate around the singularity (for the x~=2*pi*n cases)?

@bmtran
on 6 Mar 2012

I no longer take issue with test case 5, but I'm finding that it does not take care of test case 3.

Tim
on 15 Mar 2012

Results for case 3 (x=6.28318) from Mathematica, a typical Matlab closed-form solution, and the test suite are
306.9401397617041 Mathematica
306.9401397549153 Matlab
306.9401397805991 test suite
The result near 2*pi is a function of the difference between the input and 2*pi; since 6.28318 is equal to 2*pi to 6 digits, when you subtract 2*pi from it
you lose 6 digits of accuracy; the error tolerance should be set to about 10^6*eps to be fair for this case.
This is not peculiar to this function--here are results for sin(6.28318) from
Mathematica and Matlab:
-5.307179586452011e-6 Mathematica
-5.307179586686775e-6 Matlab
Again you lose about 6 digits of accuracy in Matlab.

@bmtran
on 16 Mar 2012

i agree

Claudio Gelmi
on 3 Jan 2013

I have a closed form for the series and I'm having problems with test case 3...It seems that I joined the club...

Ned Gulley
on 15 Jan 2013

There seems to be agreement that test case 3 has issues. Since the original author never returned, I commented out that test case.

2 Comments

2 Comments

**Tags**

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today