R asin() Function

The asin() function in R calculates the arcsine of a numeric input. The arcsine is the inverse operation of the sine function, and it returns the angle in radians whose sine is the given number.

Syntax

asin(number)

Parameters

number: It is a numeric value.

Return value

It returns the inverse sine of a number. The return value lies in the interval [-pi/2, pi/2] radians.

Example 1: Usage of asin()

Visual representation of R asin() Function

v1 <- -1
v2 <- 0.5
v3 <- 0


asin(v1)
asin(v2)
asin(v3)

Output

[1] -1.570796
[1] 0.5235988
[1] 0

Example 2: Using vector

Using asin() function with a vector

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

asin(vec)

Output

[1] -1.5707963 0.5235988 0.0000000 0.5235988 1.5707963

Example 3: Passing float values

# Positive float value
data_one <- asin(0.9)
print(paste0("asin(0.9): ", data_one, " radians"))

# Negative float value
data_two <- asin(-0.75)
print(paste0("asin(-0.75): ", data_two, " radians"))

# Applying asin() and then converting the result in radians to degrees
data_three <- asin(0.45) * (180.0 / pi)
print(paste0("asin(0.45): ", data_three, " degrees"))

Output

[1] "asin(0.9): 1.11976951499863 radians"
[1] "asin(-0.75): -0.848062078981481 radians"
[1] "asin(0.45): 26.743683950403 degrees"

Example 4: Plotting

vec <- seq(-1, 1, by = 0.05)

plot(dt, asin(vec), typ = "l", col = "red")

abline(v = 0, lty = 6, col = "blue")

Output

R asin() Function

That is it.

Leave a Comment