asin

expect fun asin(x: Double): Double(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.2

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-10

println(asin(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0) - PI / 2).absoluteValue < epsilon is ${(asin(1.0) - PI / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon is ${(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.123)) - 0.123).absoluteValue < epsilon is ${(asin(sin(0.123)) - 0.123).absoluteValue < epsilon}") // true

// special cases
println(asin(Double.NaN)) // NaN
println(asin(1.1)) // NaN
println(asin(-2.0)) // NaN 
   //sampleEnd
}

expect fun asin(x: Float): Float(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.2

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-6f

println(asin(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon is ${(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon is ${(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon}") // true

// special cases
println(asin(Float.NaN)) // NaN
println(asin(1.1f)) // NaN
println(asin(-2.0f)) // NaN 
   //sampleEnd
}
actual inline fun asin(x: Double): Double(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.2

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-10

println(asin(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0) - PI / 2).absoluteValue < epsilon is ${(asin(1.0) - PI / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon is ${(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.123)) - 0.123).absoluteValue < epsilon is ${(asin(sin(0.123)) - 0.123).absoluteValue < epsilon}") // true

// special cases
println(asin(Double.NaN)) // NaN
println(asin(1.1)) // NaN
println(asin(-2.0)) // NaN 
   //sampleEnd
}

actual inline fun asin(x: Float): Float(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.2

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-6f

println(asin(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon is ${(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon is ${(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon}") // true

// special cases
println(asin(Float.NaN)) // NaN
println(asin(1.1f)) // NaN
println(asin(-2.0f)) // NaN 
   //sampleEnd
}
actual inline fun asin(x: Double): Double(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.2

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-10

println(asin(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0) - PI / 2).absoluteValue < epsilon is ${(asin(1.0) - PI / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon is ${(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.123)) - 0.123).absoluteValue < epsilon is ${(asin(sin(0.123)) - 0.123).absoluteValue < epsilon}") // true

// special cases
println(asin(Double.NaN)) // NaN
println(asin(1.1)) // NaN
println(asin(-2.0)) // NaN 
   //sampleEnd
}

actual inline fun asin(x: Float): Float(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.2

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-6f

println(asin(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon is ${(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon is ${(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon}") // true

// special cases
println(asin(Float.NaN)) // NaN
println(asin(1.1f)) // NaN
println(asin(-2.0f)) // NaN 
   //sampleEnd
}
actual external fun asin(x: Double): Double(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.3

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-10

println(asin(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0) - PI / 2).absoluteValue < epsilon is ${(asin(1.0) - PI / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon is ${(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.123)) - 0.123).absoluteValue < epsilon is ${(asin(sin(0.123)) - 0.123).absoluteValue < epsilon}") // true

// special cases
println(asin(Double.NaN)) // NaN
println(asin(1.1)) // NaN
println(asin(-2.0)) // NaN 
   //sampleEnd
}

actual external fun asin(x: Float): Float(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.3

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-6f

println(asin(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon is ${(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon is ${(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon}") // true

// special cases
println(asin(Float.NaN)) // NaN
println(asin(1.1f)) // NaN
println(asin(-2.0f)) // NaN 
   //sampleEnd
}
actual fun asin(x: Double): Double(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.8

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-10

println(asin(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0) - PI / 2).absoluteValue < epsilon is ${(asin(1.0) - PI / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon is ${(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.123)) - 0.123).absoluteValue < epsilon is ${(asin(sin(0.123)) - 0.123).absoluteValue < epsilon}") // true

// special cases
println(asin(Double.NaN)) // NaN
println(asin(1.1)) // NaN
println(asin(-2.0)) // NaN 
   //sampleEnd
}

actual fun asin(x: Float): Float(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.8

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-6f

println(asin(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon is ${(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon is ${(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon}") // true

// special cases
println(asin(Float.NaN)) // NaN
println(asin(1.1f)) // NaN
println(asin(-2.0f)) // NaN 
   //sampleEnd
}
actual fun asin(x: Double): Double(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.8

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-10

println(asin(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0) - PI / 2).absoluteValue < epsilon is ${(asin(1.0) - PI / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon is ${(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.123)) - 0.123).absoluteValue < epsilon is ${(asin(sin(0.123)) - 0.123).absoluteValue < epsilon}") // true

// special cases
println(asin(Double.NaN)) // NaN
println(asin(1.1)) // NaN
println(asin(-2.0)) // NaN 
   //sampleEnd
}

actual fun asin(x: Float): Float(source)

Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2 to PI/2 radians.

Special cases:

  • asin(x) is NaN, when abs(x) > 1 or x is NaN

Since Kotlin

1.8

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-6f

println(asin(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon is ${(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon is ${(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon}") // true

// special cases
println(asin(Float.NaN)) // NaN
println(asin(1.1f)) // NaN
println(asin(-2.0f)) // NaN 
   //sampleEnd
}