How to Use the acosh() Function in R

The acosh() function in R is “used to calculate the inverse hyperbolic cosine of a value. The hyperbolic arccosine is the inverse of the hyperbolic cosine function, which means that acosh(x) = cosh-1(x).

Syntax

acosh(x)

Parameters

x: It is a numeric value, array, or vector.

Example 1

To calculate the hyperbolic arccosine in R, you can use the acosh() function. The inverse hyperbolic cosine function is defined by x == cosh(y).

acosh(1)

Output

[1] 0

If you pass the 0 to the atanh() function, it will return 0.

acosh(0)

Output

[1] 0

Example 2

Define and pass a complex value to the acosh() function.

dt <- 8 + 9i
acosh(dt)

Output

[1] 3.181721+0.845865i

Example 3

We can use the seq() function to create a series of values and pass that to the plot() function, creating a line chart.

dt <- seq(-1, 1, by = 0.01)
plot(dt, acosh(dt), type = "l", col = "red")

Output

Warning message:
In acosh(dt) : NaNs produced

The function returns the NaN value, so it can’t draw a graph based on that value.

Example 4

To create a Vector in R, use the c() function. Then pass that vector to the acosh() function.

rv <- c(-1, 0.5, 0, 0.5, 1)
acosh(rv)

Output

[1] NaN NaN NaN NaN 0
Warning message:
In acosh(rv) : NaNs produced

Example 5

The pi is an inbuilt constant in R programming, and its value is 3.141593.

Let’s find the pi constant’s acosh() value.

acosh(pi)

Output

[1] 1.811526

Let’s see another example of pi.

acosh(pi / 4)

Output

[1] NaN
Warning message:
In acosh(pi/4) : NaNs produced

That is it for acosh() function in R.

Leave a Comment