We will discuss trigonometric and hyperbolic Math functions. All these functions which takes angle as input are in radian. Similarly arc functions gives return values in radian. In practical cases we take angle in degrees thus we used macro to convert degree to radian and radian to degree.

## Trigonometric functions

• cos - Compute cosine `double sin(double);`
• sin - Compute sine `double cos(double);`
• tan - Compute tangent `double tan(double);`
• acos - Compute arc cosine `double acos(double);`
• asin - Compute arc sine `double asin(double);`
• atan - Compute arc tangent `double atan(double);`
• atan2 - Compute arc tangent with two parameters `double atan2(double, double);`

## Hyperbolic functions

• cosh Compute hyperbolic cosine `double cosh(double);`
• sinh Compute hyperbolic sine `double sinh(double);`
• tanh Compute hyperbolic tangent `double tanh(double);`

``` 1  #include<stdio.h>
2  #include<math.h>
3
5  #define RAD2DEG(x) (double)(x *180 *7)/22
6
7  int main (int argc, char * argv[])
8  {
9    printf ("sin(%d) = %.2lf\n", 30, sin(DEG2RAD(30)));
10    printf ("cos(%d) = %.2lf\n", 60, cos(DEG2RAD(60)));
11    printf ("tan(%d) = %.2lf\n", 45, tan(DEG2RAD(45)));
12
13    printf ("asin(%.2f) = %.0lf\n", 0.5f, RAD2DEG(asin((double)0.5)));
14    printf ("acos(%.2f) = %.0lf\n", 0.5f, RAD2DEG(acos((double)0.5)));
15    printf ("atan(%.2f) = %.0lf\n", 1.0f, RAD2DEG(atan((double)1)));
16    printf ("atan2(%.2f/%.f) = %.0lf\n", sqrt(3), 3.0f, RAD2DEG(atan2((double)sqrt(3),3)));
17
18  }```

## output

```sin(30) = 0.50
cos(60) = 0.50
tan(45) = 1.00
asin(0.50) = 30
acos(0.50) = 60
atan(1.00) = 45
atan2(1.73/3) = 30
```

You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.

0

Similar topics related to this section