Home > Backend Development > C++ > body text

C++ program to find the value of the inverse hyperbolic sine function taking a given value as argument

WBOY
Release: 2023-09-17 10:49:02
forward
663 people have browsed it

C++ program to find the value of the inverse hyperbolic sine function taking a given value as argument

Hyperbolic functions are defined using hyperbolas instead of circles and are equivalent to ordinary trigonometric functions. It returns the ratio parameter in the hyperbolic sine function from the supplied angle in radians. But do the opposite, or in other words. If we want to calculate an angle from a hyperbolic sine, we need an inverse hyperbolic trigonometric operation like the hyperbolic inverse sine operation.

This lesson will demonstrate how to use the hyperbolic inverse sine (asinh) function in C to calculate angles using the hyperbolic sine value in radians. The hyperbolic arcsine operation follows the following formula -

$$\mathrm{sinh^{-1}x\:=\:In(x\: \:\sqrt{x^2\: \:1})}, where\:In\:is\ :Natural logarithm\:(log_e \: k)$$

asinh() function

According to the hyperbolic sine value, the angle can be calculated using the asinh() function. This function comes with the C standard library. Before using this function we must import the cmath library. This method returns the angle in radians and takes the sine value as argument. The following uses simple syntax -

grammar

#include < cmath >
asinh( <hyperbolic sine value> )
Copy after login

algorithm

  • Take the hyperbolic sine value x as input
  • Use asinh(x) to calculate sinh−1(x)
  • Return results.

Example

#include <iostream>
#include <cmath>
using namespace std;

float solve( float x ) {
   float answer;
   answer = asinh( x );
   return answer;
}

int main()
{
   float angle, ang_deg;
   angle = solve( 2.3013 );
   ang_deg = angle * 180 / 3.14159;

   cout << "The angle (in radian) for given hyperbolic sine value 2.3013 is: " << angle << " = " << ang_deg << " (in degrees)" << endl;

   angle = solve( 11.5487 );
   ang_deg = angle * 180 / 3.14159;

   cout << "The angle (in radian) for given hyperbolic sine value 11.5487 is: " << angle << " = " << ang_deg << " (in degrees)" << endl;

   angle = solve( 0.86867 );
   ang_deg = angle * 180 / 3.14159;

   cout << "The angle (in radian) for given hyperbolic sine value 0.86867 is: " << angle << " = " << ang_deg << " (in degrees)" << endl;

   angle = solve( -0.86867 );
   ang_deg = angle * 180 / 3.14159;

   cout << "The angle (in radian) for given hyperbolic sine value - 0.86867 is: " << angle << " = " << ang_deg << " (in degrees)" << endl;
}
Copy after login

Output

The angle (in radian) for given hyperbolic sine value 2.3013 is: 1.5708 = 90.0001 (in degrees)
The angle (in radian) for given hyperbolic sine value 11.5487 is: 3.14159 = 180 (in degrees)
The angle (in radian) for given hyperbolic sine value 0.86867 is: 0.785397 = 45 (in degrees)
The angle (in radian) for given hyperbolic sine value - 0.86867 is: -0.785397 = -45 (in degrees)
Copy after login

The asinh() method in this case receives the hyperbolic sine value and returns the angle in radian format. We convert this output from radians to degrees using the formula below.

$$\mathrm{\theta_{deg}\:=\:\theta_{rad}\:\times\frac{180}{\pi}}$$

in conclusion

To perform inverse hyperbolic operations using sine values, we use the asinh() function from the cmath package. After receiving a hyperbolic sine value as input, the function outputs the desired angle in radians. In older versions of C and C, the return type is double; later versions of C also use overloaded forms of float and long-double. When an integer value is passed as an argument, the asinh() function is called after converting the input argument to type double.

The above is the detailed content of C++ program to find the value of the inverse hyperbolic sine function taking a given value as argument. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!