Current location - Quotes Website - Collection of slogans - How to input trigonometric function in C language programming?
How to input trigonometric function in C language programming?
Must have a math library at the beginning? # include & ltmath.h & gt

Then it is commonly used.

Sin (x)

cos(x)

Tan (x)

Where x must be in radians. For example, if you want to calculate the sine value of 30 degrees in degrees, you should use

Forms of sin (x *180/3.1415926)

anti-sine

arccos(x)

arctan(x)

arccot(x)

The above four are corresponding inverse trigonometric functions, and the unit of function value is radian. If the degree of arc tangent (1) is required, it should be in the following form:? arctan( 1)* 180/3. 14 15926

Extended data

The unit of trigonometric function library in C language is radian. If you want to use angles, you must convert them into radians, or rewrite a trigonometric function library.

Convert angles into radians before calling trigonometric functions, and convert radians into angles after calling inverse trigonometric functions. You can use pi = 4.0 * atan( 1) to calculate pi, and use a = d/180.0*pi to convert angles into radians.

For example: sin (45/180.0 * pi); It's the calculated sin45.

References:

C language-Baidu encyclopedia