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);

#include<stdio.h>
#include<math.h>
#define DEG2RAD(x) (double)(22*x)/(7*180)
#define RAD2DEG(x) (double)(*180 *7)/22
int main (int argc, char * argv[])
{
  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.

 Vote 0

Similar topics related to this section

access C from VB, JNI C from Java, arithmeic math, trigonometric, fopen, fdopen, write vs append mode,

# C Programming Language (Prentice Hall Software)
# Let Us C Paperback - 2006 by Yashavant Kanetkar
# Understanding and Using C Pointers Core techniques for memory management
# Data Structures Using C and C++ Paperback - 1998
# Data Structures In C Paperback - August 11, 2008 by Noel Kalicharan