C++ Inverse Trigonometric functions














































C++ Inverse Trigonometric functions



 The C++ <cmath> header file declares a set of functions to perform mathematical   operations such as the elementary exponential, logarithm, square root, and trigonometric   functions etc.
 Note:- All the functions take input in radians and not degrees
 1. asin( ) - This function takes angle (in radians) as an argument and returns its inverse
sine value.
asin(x) = sin-1 x
         Syntax :- float asin(float x);
                         double asin(double x);
                         long double asin(long double x);
                         double asin(T x);  ( for integral type )

         Parameter :- The asin() function takes a single mandatory argument in the range
[-1, 1]. It is because the value of sine is in the range of 1 and -1.

         Return value :- The asin() function returns the value in the range of [-π/2, π/2]. The                                         returned value is either in double, float, or long double.

 2. acos( )This function takes angle (in radians) as an argument and returns its inverse
cosine value.
acos(x) = cos-1 x
         Syntax :- double acos(double x);
                         float acos(float x);
                         long double acos(long double x);
                         double acos(T x); ( Here, T is an integral type )

         Parameter :- The acos() function takes a single mandatory argument in the range
[-1, 1]. It is because the value of cosine is in the range of 1 and -1.

         Return value :- The acos() function returns the value in the range of [0, π]. The                                                 returned value is either in double, float, or long double.

 3. atan( )This function takes angle (in radians) as an argument and returns its inverse
tangent value.
atan(x) = tan-1 x
         Syntax :- float atan(float x);
                         double atan(double x);
                         long double atan(long double x);
                         double atan (T x);  ( for integral type )

         Parameter :- The tan() function takes a single mandatory argument in radians.

         Return value :- The atan() function returns the value in the range of [-π/2, π/2].

4. atan2( ) - This function takes angle (in radians) as an argument and returns the
inverse tangent of a coordinate a/b in radian.
atan2( ) = tan-1 ( y / x)
         Syntax :- atan2(double y, double x)

         Parameter :- The atan2() function takes two arguments x and y respectively in
radians where x is a floating-point number that represents the
proportion of the x-coordinate and y is a floating-point number
that represents the proportion of the y-coordinate.

         Return value :- The atan2() function returns a floating-point value in the range of
[-π, π] and in a special case it returns 0 when both x and y are 0.

 Code of Trigonometric functions all together :
#include <iostream>
#include <cmath>
using namespace std;

int main() {
double x, y;
cout << "Enter the value of number x : ";
cin >> x;
cout<<"Inverse sine value of x = "<< x <<" is => "<< asin(x) << endl;
cout<<"Inverse cosine value of x = "<< x <<" is => "<<acos(x)<< endl;

x =
3.2;
cout << "\nEnter the value of number y : ";
cin >> y;
cout<<"\n\nInverse Tangent value of x = "<<x<<" is => "<<atan(x);
cout<<"\nInverse Tangent value of y / x is => "<<atan2(y, x)<<endl;
return 0;
}


Output:-
  Enter the value of number x : 0.6
  Inverse sine value of x = 0.6 is => 0.643501
  Inverse cosine value of x = 0.6 is => 0.927295

  Enter the value of number y : 2.8

  Inverse Tangent value of x = 3.2 is => 1.26791
  Inverse Tangent value of y / x is => 0.71883


Comments