/*--------------------------------------------------------------* To modify generated output--Fourier 10 Order Line *--------------------------------------------------------------*/ #include <math.h> #include <stdio.h> #include <stdlib.h> double eqn6850(double x); void main(void) { double x,y; char str[80]; while(1){ printf("Enter x: "); gets(str); if(!*str) break; sscanf(str,"%lg",&x); y=eqn6850(x); printf(" y=%.15lg\n",y); } } /*--------------------------------------------------------------*/ double evalfpoly(int order, double x, double *c) /*--------------------------------------------------------------*/ { int i,j; double y=c[0]; x=(x-(1.000000000000000))/(1027.186002715093); for(i=1,j=1;j<=order;j+=2,i++) y += c[j]*cos(i*x)+c[j+1]*sin(i*x); return y; } /*--------------------------------------------------------------*/ double eqn6850(double x) /*--------------------------------------------------------------* a= -1988.532414673345 b= -3116.002162637732 c= 3644.662403802266 d= 2784.33539011638 e= 5149.024722269687 f= 5589.036234895881 g= -1740.995541288461 h= -852.5205018672013 i= -4685.18583825292 j= -3157.372613975506 k= 291.0488944901461 l= 38.19166147677898 m= 1716.365402621813 n= 738.0280483169678 o= 26.91111687090461 p= 21.09628861488089 q= -239.3793336551126 r= -52.8543381119665 s= -7.07871238136268 t= -1.0580188789772 u= 6.013791704694437 *--------------------------------------------------------------*/ { double y; static double c[]= { -1988.532414673345, -3116.002162637732, 3644.662403802266, 2784.335390116380, 5149.024722269687, 5589.036234895881, -1740.995541288461, -852.5205018672013, -4685.185838252920, -3157.372613975506, 291.0488944901461, 38.19166147677898, 1716.365402621813, 738.0280483169678, 26.91111687090461, 21.09628861488089, -239.3793336551126, -52.85433811196650, -7.078712381362680, -1.058018878977200, 6.013791704694437, }; y=evalfpoly(20,x,c); return(y); }Much better. XD
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
A mathematical model of C# language, apply to change into MT4 indicator !!
/*--------------------------------------------------------------*
To modify generated output--Fourier 10 Order Line
*--------------------------------------------------------------*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
double eqn6850(double x);
void main(void)
{
double x,y;
char str[80];
while(1){
printf("Enter x: ");
gets(str);
if(!*str) break;
sscanf(str,"%lg",&x);
y=eqn6850(x);
printf(" y=%.15lg\n",y);
}
}
/*--------------------------------------------------------------*/
double evalfpoly(int order, double x, double *c)
/*--------------------------------------------------------------*/
{
int i,j;
double y=c[0];
x=(x-(1.000000000000000))/(1027.186002715093);
for(i=1,j=1;j<=order;j+=2,i++)
y += c[j]*cos(i*x)+c[j+1]*sin(i*x);
return y;
}
/*--------------------------------------------------------------*/
double eqn6850(double x)
/*--------------------------------------------------------------*
a= -1988.532414673345
b= -3116.002162637732
c= 3644.662403802266
d= 2784.33539011638
e= 5149.024722269687
f= 5589.036234895881
g= -1740.995541288461
h= -852.5205018672013
i= -4685.18583825292
j= -3157.372613975506
k= 291.0488944901461
l= 38.19166147677898
m= 1716.365402621813
n= 738.0280483169678
o= 26.91111687090461
p= 21.09628861488089
q= -239.3793336551126
r= -52.8543381119665
s= -7.07871238136268
t= -1.0580188789772
u= 6.013791704694437
*--------------------------------------------------------------*/
{
double y;
static double c[]= {
-1988.532414673345,
-3116.002162637732,
3644.662403802266,
2784.335390116380,
5149.024722269687,
5589.036234895881,
-1740.995541288461,
-852.5205018672013,
-4685.185838252920,
-3157.372613975506,
291.0488944901461,
38.19166147677898,
1716.365402621813,
738.0280483169678,
26.91111687090461,
21.09628861488089,
-239.3793336551126,
-52.85433811196650,
-7.078712381362680,
-1.058018878977200,
6.013791704694437,
};
y=evalfpoly(20,x,c);
return(y);
}