Rakesh94
Uploaded by
3 SLIDES
1 VIEWS
0LIKES

SINX-C

DESCRIPTION

SINX PROGRAM

1 / 3

Download Presentation

SINX-C

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Develop Develop a a program Compare Compare your your result program to to compute result with with built compute sin(x) built in in library sin(x) using library function function. . using Taylor Taylor series series approximation approximation. . printf("The sine function is %f", sin(x)); x- radians input – degree x = degree * (PI/180) term = nume/deno nume =x deno = 1 i =2 term = nume / deno nume = - nume * x * x = -x3 deno = deno * i * (i+1) = 1*2* (2+1) = 6 sum = sum + term i = i + 2 term = nume / deno nume = - (-x3) * x * x = x5 deno = deno*i*(i+1) = 6* 4*(4+1) = 120 sum = sum + term

  2. Develop Develop a a program Compare Compare your your result program to to compute result with with built compute sin(x) built in in library sin(x) using library function function. . using Taylor Taylor series series approximation approximation. . #include<stdio.h> #include<stdio.h> #include<math.h> #define PI 3.142 void main() { int i, degree; float x, sum=0, term, nume, deno; printf("Enter the value of degree"); scanf("%d", &degree); x = degree * (PI/180); //converting degree into radian nume = x; deno = 1; i=2;

  3. Develop Develop a a program Compare Compare your your result program to to compute result with with built compute sin(x) built in in library sin(x) using library function function. . using Taylor Taylor series series approximation approximation. . do { //calculating the sine value. term = nume/deno; nume = -nume*x*x; deno = deno*i*(i+1); sum=sum+term; i=i+2; } while (fabs(term) >= 0.00001); // Accurate to 4 digits printf("The sine of %d is %.3f\n", degree, sum); printf("The sine function of %d is %.3f", degree, sin(x)); }

More Related