In Swift, the acosh()
function returns the inverse hyperbolic cosine of a number. The image below shows the mathematical representation of the acosh()
function.
Here’s how the acosh()
function is used.
acosh(number)
//number can be real, float, or double.
Note: We need to import
Foundation
in our code to use theacosh()
function. This can be done using theimport Foundation
command.
A number
needs to be passed as an argument to the function. This number can be real, float, or double.
The value of the input argument should be greater than or equal to 1.
The value returned by acosh()
is the inverse hyperbolic cosine of number
.
Let’s run a script that uses the acosh()
method.
import Swiftimport Foundation//positive numberprint("The value of acosh(1.5) :", acosh(1.5));// 1print("The value of acosh(1.0) :", acosh(1.0));//less than 1print("The value of acosh(0.0): ",acosh(0.0) );print("The value of acosh(-1.5): ",acosh(-1.5) );
Foundation
header that is required for acosh()
function.1.5
using acosh()
. This is the example we’ve used for an input argument greater than 1. We can see that the output is greater than 0.acosh()
. The output for this is 0.acosh()
. These do not compute, and return nan
.