I'm getting the "-1.#IND00" as a solution to this Fourier series.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int n, x=50, L=100, q1=2;
float pi = 3.141592;
float flux1=0;
double flux2=0;
for(n=0;n<=50;n++)
{
flux1=q1*(2/(pi*n))*(cos(n*pi)-1)*(sin((n*pi*(x+L))/(2*L)));
flux2+=flux1;
}
flux2+=q1;
printf("%f\n", flux2);
return 0;
}
flux2 is coming out as "-1.#IND00" I can't work out why, since each term in the sum, (flux1), comes out as a rational number and the sum seems to converge.
Can you guys help?