R acosh() Function

The acosh() function in R is used to compute the inverse hyperbolic cosine of a number or a numeric vector.

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: Usage of acosh() function

acosh() Function in R

acosh(1)

Output

[1] 0

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

acosh() returns 0

acosh(0)

Output

[1] 0

Example 2: Passing complex value

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

passing complex vector

complex_vec <- 8 + 9i

acosh(complex_vec)

Output

[1] 3.181721+0.845865i

Example 3: Plotting

# Define the domain (from 1 to, say, 5)
x <- seq(1, 5, by = 0.1)

# Compute acosh for these x values
y <- acosh(x)

# Plot the function
plot(x, y,
  type = "l", col = "blue",
  main = "Plot of acosh(x)", xlab = "x", ylab = "acosh(x)"
)

Output

Plotting of acosh()

Example 4: Passing a vector

Passing a vector

vec <- c(-1, 0.5, 0, 0.5, 1)

acosh(vec)

Output

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

Example 5: Passing pi

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.

Leave a Comment