acos
Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-10
println(acos(1.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0) - PI / 2).absoluteValue < epsilon is ${(acos(0.0) - PI / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0) - PI).absoluteValue < epsilon is ${(acos(-1.0) - PI).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.123)) - 0.123).absoluteValue < epsilon is ${(acos(cos(0.123)) - 0.123).absoluteValue < epsilon}") // true
// special cases
println(acos(Double.NaN)) // NaN
println(acos(1.1)) // NaN
println(acos(-2.0)) // NaN
//sampleEnd
}Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-6f
println(acos(1.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon is ${(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon is ${(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon}") // true
// special cases
println(acos(Float.NaN)) // NaN
println(acos(1.1f)) // NaN
println(acos(-2.0f)) // NaN
//sampleEnd
}Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-10
println(acos(1.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0) - PI / 2).absoluteValue < epsilon is ${(acos(0.0) - PI / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0) - PI).absoluteValue < epsilon is ${(acos(-1.0) - PI).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.123)) - 0.123).absoluteValue < epsilon is ${(acos(cos(0.123)) - 0.123).absoluteValue < epsilon}") // true
// special cases
println(acos(Double.NaN)) // NaN
println(acos(1.1)) // NaN
println(acos(-2.0)) // NaN
//sampleEnd
}Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-6f
println(acos(1.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon is ${(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon is ${(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon}") // true
// special cases
println(acos(Float.NaN)) // NaN
println(acos(1.1f)) // NaN
println(acos(-2.0f)) // NaN
//sampleEnd
}Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-10
println(acos(1.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0) - PI / 2).absoluteValue < epsilon is ${(acos(0.0) - PI / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0) - PI).absoluteValue < epsilon is ${(acos(-1.0) - PI).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.123)) - 0.123).absoluteValue < epsilon is ${(acos(cos(0.123)) - 0.123).absoluteValue < epsilon}") // true
// special cases
println(acos(Double.NaN)) // NaN
println(acos(1.1)) // NaN
println(acos(-2.0)) // NaN
//sampleEnd
}Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-6f
println(acos(1.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon is ${(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon is ${(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon}") // true
// special cases
println(acos(Float.NaN)) // NaN
println(acos(1.1f)) // NaN
println(acos(-2.0f)) // NaN
//sampleEnd
}Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-10
println(acos(1.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0) - PI / 2).absoluteValue < epsilon is ${(acos(0.0) - PI / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0) - PI).absoluteValue < epsilon is ${(acos(-1.0) - PI).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.123)) - 0.123).absoluteValue < epsilon is ${(acos(cos(0.123)) - 0.123).absoluteValue < epsilon}") // true
// special cases
println(acos(Double.NaN)) // NaN
println(acos(1.1)) // NaN
println(acos(-2.0)) // NaN
//sampleEnd
}Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-6f
println(acos(1.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon is ${(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon is ${(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon}") // true
// special cases
println(acos(Float.NaN)) // NaN
println(acos(1.1f)) // NaN
println(acos(-2.0f)) // NaN
//sampleEnd
}Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-10
println(acos(1.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0) - PI / 2).absoluteValue < epsilon is ${(acos(0.0) - PI / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0) - PI).absoluteValue < epsilon is ${(acos(-1.0) - PI).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.123)) - 0.123).absoluteValue < epsilon is ${(acos(cos(0.123)) - 0.123).absoluteValue < epsilon}") // true
// special cases
println(acos(Double.NaN)) // NaN
println(acos(1.1)) // NaN
println(acos(-2.0)) // NaN
//sampleEnd
}Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-6f
println(acos(1.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon is ${(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon is ${(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon}") // true
// special cases
println(acos(Float.NaN)) // NaN
println(acos(1.1f)) // NaN
println(acos(-2.0f)) // NaN
//sampleEnd
}Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-10
println(acos(1.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0) - PI / 2).absoluteValue < epsilon is ${(acos(0.0) - PI / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0) - PI).absoluteValue < epsilon is ${(acos(-1.0) - PI).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.123)) - 0.123).absoluteValue < epsilon is ${(acos(cos(0.123)) - 0.123).absoluteValue < epsilon}") // true
// special cases
println(acos(Double.NaN)) // NaN
println(acos(1.1)) // NaN
println(acos(-2.0)) // NaN
//sampleEnd
}Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0 to PI radians.
Special cases:
acos(x)isNaN, whenabs(x) > 1or x isNaN
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-6f
println(acos(1.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// acos(0.0) = π/2
println("(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(acos(0.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// acos(-1.0) = π
println("(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon is ${(acos(-1.0f) - PI.toFloat()).absoluteValue < epsilon}") // true
// acos(cos(x)) = x
println("(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon is ${(acos(cos(0.25f)) - 0.25f).absoluteValue < epsilon}") // true
// special cases
println(acos(Float.NaN)) // NaN
println(acos(1.1f)) // NaN
println(acos(-2.0f)) // NaN
//sampleEnd
}