Home > Back-end >  Taylor formula of sine: excuse me, where is wrong?
Taylor formula of sine: excuse me, where is wrong?

Time:10-26

CodePudding user response:

# include & lt; stdio.h>
# include & lt; Math. H>
Float mypow (float a, int b)
{
Float result=1;
For (int I=1; i<=b; I++)
{
Result *=a;
}
return result;
}
Int fun (int a)
{
Int result=1;
For (int I=1; i<=a; I++)
{
Result *=I;
}
return result;
}
Int main ()
{

Double x, eps, a1=1;
Printf (" Enter the x & amp; Eps: ");
Lf the scanf (" % % lf ", & amp; X, & amp; Eps);
Float t=sin (x);
Double sum=0;
int n;


For (n=0; Fabs (t - sum) & lt; Eps; N++)
{
The sum +=(mypow mypow (a1, n) * (x, 2 * n + 1))/fun (2 * n + 1);
}

Printf (" sin (% f)=% f \ n ", x, t);
Printf (" % d, sin (% f)=% f \ n ", n - 1, x, sum);

}
  • Related