Let the series (development of \(\int_0^x\cos{\frac{\pi t^2}{2}}dt\) - Fresnel integral) \(C(x)=\sum_{n=0}^{n=+\infty}\alpha_n(x)\)
the \(\alpha_n\) being defined by \(\alpha_0(x)=x\) and the recurrence formula \(\alpha_{n+1}(x)=-\frac{4n+1}{(2n+2)(2n+1)(4n+5)}(\frac{\pi}{2})^2x^4\alpha_n(x)\)
Write a program calculating \(C(x)\) for x = 0.5 by summing the series to the first term below \(\epsilon=10^{-12}\) excluded.
Difficulty level
![](images/star3.png)
This exercise is mostly suitable for students
#include <stdio.h>
#include <math.h>
#include <conio.h>
void main()
{
int n;
double x,s,eps=1.e-12,pi=acos(-1.),c,a,cx4;
c=pi/2.; c=c*c;
x=0.5; a=x; s=0; n=0; cx4=c*x*x*x*x;
while(fabs(a)>=eps)
{
printf("a=%lf\n",a);
s+=a;
a=-a*(4*n+1)/(2*n+2)/(2*n+1)/(4*n+5)*cx4;
n++;
}
printf("C(%lf)=%lf\n",x,s);
getch();
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
![](images/star4.png)