Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Need help with a math program

A simple college student here with a problem. I need to write a program to find sin(x) where x is between 0.0 and 2.0, counting by 0.1. I need to use the MacLauren series and the only hint that I was given is that the ratio between the ith term and the (i+1)th term is

-(x^2)/((2i + 2)*(2i + 3)). I'm supposed to use 15 terms for i. Could someone please tell me what's wrong with my code? If this isn't an appropriate board to post this message, could you tell me where I can post? The code for my program follows this message:



#include
#include

main()
{

double sine = 0;
double x = 0.0;
double difference = 0;
int i;
printf("Number My sin() C Sin Difference
");

for(x = 0.0; x < 2.1; x += .1)
{
for(i = 1; i <= 15; i+=1)
{
float term = -(pow(x,2))/(((2*i) + 3) * ((2*i) + 2));
float nextterm = -(pow(x,2))/((2*(i+1) + 3) * (2*(i+1) + 2));
sine += term*nextterm;
}
difference = sin(x)-sine;
printf("%6.1lf %6lf %6lf %6lf
", x, sine, sin(x), difference);
}
}

Sign In or Register to comment.