The
math.h header contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. In order to use these functions you need to include header file
math.h.
Note: All the functions take input in radians and not degrees
Below are the various trigonometric functions that can be used from the math.h header:
- sin: This function takes angle (in radians) as an argument and returns its sine value that could be verified using a sine curve.
Example:
Output:
Sine value of x = 2.3: 0.745705
- cos: This function takes angle (in radians) as an argument and return its cosine value that could be verified using cosine curve.
Example:
Output:
Cosine value of x = 2.3: -0.666276
- tan: This function takes angle (in radians) as an argument and return its tangent value. This could also be verified using Trigonometry as Tan(x) = Sin(x)/Cos(x).
Example:
Output:
Tangent value of x = 2.3: -1.11921
- acos: This function returns the arc cosine of argument. The argument to acos must be in the range -1 to 1; otherwise, a domain error occurs.
Example:
Output:
Arc Cosine value of x = 1.0: 0
- asin: This function returns the arcsine of argument. The argument to asin must be in the range -1 to 1; otherwise, a domain error occurs.
Example:
Output:
Arc Sine value of x = 1.0: 1.5708
- atan: This function returns the arc tangent of arg.
Example:
Output:
Arc Tangent value of x = 1.0: 0.785398
- atan2: This function returns the arc tangent of (a)/(b).
Example:
Output:
Arc Tangent 2 value of x = 2.3 and y = 1.0: 1.16067
- cosh: This function returns the hyperbolic cosine of argument provided. The value of the argument provided must be in radians.
Example:
Output:
Hyperbolic Cosine of x=57.3: 3.83746e+24
- tanh: This function returns the hyperbolic tangent of argument provided. The value of argument provided must be in radians.
Example:
Output:
Hyperbolic Tangent of x=57.3: 1
Below are the trigonometric functions all together:
Output:
Sine value of x = 2.3: 0.745705
Cosine value of x = 2.3: -0.666276
Tangent value of x = 2.3: -1.11921
Arc Cosine value of x = 1.0: 0
Arc Sine value of x = 1.0: 1.5708
Arc Tangent value of x = 1.0: 0.785398
Hyperbolic Cosine of x=57.3: 3.83746e+24
Hyperbolic tangent of x=57.3: 1