What is the acosh() function in D?
Overview
The acosh() function returns the inverse hyperbolic cosine of a number.
We can see the mathematical representation of the acosh() function below.
Note:
std.mathis required for this function.
Syntax
acosh(number) //number can be real, float, or double.
Parameters
This function requires a number as a parameter. The value of the parameter should be greater than or equal to 1.
Return value
acosh() returns the inverse hyperbolic cosine of a number that is sent as a parameter.
Code
The following code shows how to use the acosh() function in D.
import core.stdc.stdio;import std.stdio;//header required for functionimport std.math;int main() {//positive numberwriteln("The value of acosh(1.5) :", acosh(1.5));// 1writeln("The value of acosh(1.0) :", acosh(1.0));//less than 1writeln("The value of acosh(0.0): ",acosh(0.0) );writeln("The value of acosh(-1.5): ",acosh(-1.5) );return 0;}
Explanation
- Line 4: We add the
std.mathheader required foracosh()function. - Line 8: We calculate the inverse hyperbolic cosine of the positive number greater than 1 using
acosh(). - Line 11: We calculate inverse hyperbolic cosine of 1 using
acosh().
- Lines 14–15: We calculate the inverse hyperbolic cosine of the number less than 1 using
acosh().