Hi guys hope you're doing well
so this is my assigment
Maths3assignment2-no3 (2).pdf
this is as far as I got in the code, problem is I'm not getting the same accuray for the output for the program, in comparison with a calculator.
also I'm trying to display each iteration of the accuray for the output but I think that's wrong as well for e.g.
-----------------------------------------
ITERATIONS -------- value
-----------------------------------------
ITERATION 1 -------: 2.500000
ITERATION 2 -------: 2.750000
ITERATION 3 -------: 2.625000
ITERATION 4 -------: 2.687500
ITERATION 5 -------: 2.718750
....
....
....
ITERATION 20-------: 2.740645
and so on..
I had a read of
Code:
http://blogs.ubc.ca/infiniteseriesmodule/units/unit-3-power-series/taylor-series/maclaurin-expansion-of-sinx/
but no luck .. you're gudince is my only help
thank you
Code:
/* PROGRAM FOR SUM OF SIN (X) SERIES *//*x -x^3/3! + x^5/5! - .........*/
#include<stdio.h>
int main()
{
int x,n,t=1,i,j;
double num,sum=0.0,r;
long int deno;
printf("\n\t\tINPUT:");
printf("\n\t\t------");
printf("\n\t\tEnter the value for x: ");
scanf("%d",&x);
printf("\n\t\tEnter the value for n: ");
scanf("%d",&n);
printf("\n\t\tOUTPUT:");
printf("\n\t\t-------");
r=x*(3.14/180.0);
printf("\n\t\tThe radius value for the given x value is: %lf",r);
for(i=1;i<=n;i+=2)
{
num=1.0;
deno=1;
for(j=1;j<=i;j++)
{
num=num*r;
deno=deno*j;
}
sum=sum+num/deno*t;
t=t*-1;
printf("\n\t\tThe value for sin %d is: %.11f",x,sum);
}
printf("\n\n\n");
return 0;
}