Current location - Training Enrollment Network - Mathematics courses - How to calculate sine and cosine functions with special mathematical algorithms in C language
How to calculate sine and cosine functions with special mathematical algorithms in C language
The header file contains. Mathematics. h

cosine function

Function prototype: double cos (double X);

Header file: # include

Is this a standard function? Yes

Function: Find the cosine of x, where x is radian.

Return value: the double precision value of the calculation result.

The routine is as follows: find cosx.

# include & ltstdio.h & gt

# include & ltmath.h & gt

int main(void)

{

Double results;

double x = M _ PI

Result = cos (x);

Printf("cos(PI) is %lf\n ",result);

Returns 0;

}

Sine: Sine function

Function prototype: double sin (double x);

Header file: # include

Is this a standard function? Yes

Function: Find the sine of x, where x is radian.

Return value: the double precision value of the calculation result.

The routine is as follows: find sinx.

# include & ltstdio.h & gt

# include & ltmath.h & gt

int main(void)

{

Floating x;

x = M _ PI/2;

printf("sin(PI/2)=%f ",sin(x));

getchar();

Returns 0;

}