atan
Требования к платформе и версии: Common (1.2), Wasm-JS (1.8), Wasm-WASI (1.8)
expect fun atan(x: Double): Double
Вычисляет арктангенс значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.
Особые случаи:
atan(NaN)— этоNaN
Примеры
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-10
println(atan(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// atan(1.0) = π/4
println("(atan(1.0) - PI / 4).absoluteValue < epsilon is ${(atan(1.0) - PI / 4).absoluteValue < epsilon}") // true
// atan(-1.0) = -π/4
println("(atan(-1.0) - (-PI / 4)).absoluteValue < epsilon is ${(atan(-1.0) - (-PI / 4)).absoluteValue < epsilon}") // true
// atan(tan(x)) = x
println("(atan(tan(0.123)) - 0.123).absoluteValue < epsilon is ${(atan(tan(0.123)) - 0.123).absoluteValue < epsilon}") // true
// special cases
println(atan(Double.NaN)) // NaN
//sampleEnd
}
expect fun atan(x: Float): Float
Вычисляет арктангенс значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.
Особые случаи:
atan(NaN)— этоNaN
Примеры
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-6f
println(atan(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// atan(1.0) = π/4
println("(atan(1.0f) - PI.toFloat() / 4).absoluteValue < epsilon is ${(atan(1.0f) - PI.toFloat() / 4).absoluteValue < epsilon}") // true
// atan(-1.0) = -π/4
println("(atan(-1.0f) - (-PI.toFloat() / 4)).absoluteValue < epsilon is ${(atan(-1.0f) - (-PI.toFloat() / 4)).absoluteValue < epsilon}") // true
// atan(tan(x)) = x
println("(atan(tan(0.25f)) - 0.25f).absoluteValue < epsilon is ${(atan(tan(0.25f)) - 0.25f).absoluteValue < epsilon}") // true
// special cases
println(atan(Float.NaN)) // NaN
//sampleEnd
}
Требования к платформе и версии: JS (1.2), JVM (1.2)
actual inline fun atan(x: Double): Double
Вычисляет арктангенс значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.
Особые случаи:
atan(NaN)— этоNaN
Примеры
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-10
println(atan(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// atan(1.0) = π/4
println("(atan(1.0) - PI / 4).absoluteValue < epsilon is ${(atan(1.0) - PI / 4).absoluteValue < epsilon}") // true
// atan(-1.0) = -π/4
println("(atan(-1.0) - (-PI / 4)).absoluteValue < epsilon is ${(atan(-1.0) - (-PI / 4)).absoluteValue < epsilon}") // true
// atan(tan(x)) = x
println("(atan(tan(0.123)) - 0.123).absoluteValue < epsilon is ${(atan(tan(0.123)) - 0.123).absoluteValue < epsilon}") // true
// special cases
println(atan(Double.NaN)) // NaN
//sampleEnd
}
actual inline fun atan(x: Float): Float
Вычисляет арктангенс значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.
Особые случаи:
atan(NaN)— этоNaN
Примеры
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-6f
println(atan(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// atan(1.0) = π/4
println("(atan(1.0f) - PI.toFloat() / 4).absoluteValue < epsilon is ${(atan(1.0f) - PI.toFloat() / 4).absoluteValue < epsilon}") // true
// atan(-1.0) = -π/4
println("(atan(-1.0f) - (-PI.toFloat() / 4)).absoluteValue < epsilon is ${(atan(-1.0f) - (-PI.toFloat() / 4)).absoluteValue < epsilon}") // true
// atan(tan(x)) = x
println("(atan(tan(0.25f)) - 0.25f).absoluteValue < epsilon is ${(atan(tan(0.25f)) - 0.25f).absoluteValue < epsilon}") // true
// special cases
println(atan(Float.NaN)) // NaN
//sampleEnd
}
Требования к платформе и версии: Native (1.3)
actual external fun atan(x: Double): Double
Вычисляет арктангенс значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.
Особые случаи:
atan(NaN)— этоNaN
Примеры
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-10
println(atan(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// atan(1.0) = π/4
println("(atan(1.0) - PI / 4).absoluteValue < epsilon is ${(atan(1.0) - PI / 4).absoluteValue < epsilon}") // true
// atan(-1.0) = -π/4
println("(atan(-1.0) - (-PI / 4)).absoluteValue < epsilon is ${(atan(-1.0) - (-PI / 4)).absoluteValue < epsilon}") // true
// atan(tan(x)) = x
println("(atan(tan(0.123)) - 0.123).absoluteValue < epsilon is ${(atan(tan(0.123)) - 0.123).absoluteValue < epsilon}") // true
// special cases
println(atan(Double.NaN)) // NaN
//sampleEnd
}
actual external fun atan(x: Float): Float
Вычисляет арктангенс значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.
Особые случаи:
atan(NaN)— этоNaN
Примеры
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val epsilon = 1e-6f
println(atan(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// atan(1.0) = π/4
println("(atan(1.0f) - PI.toFloat() / 4).absoluteValue < epsilon is ${(atan(1.0f) - PI.toFloat() / 4).absoluteValue < epsilon}") // true
// atan(-1.0) = -π/4
println("(atan(-1.0f) - (-PI.toFloat() / 4)).absoluteValue < epsilon is ${(atan(-1.0f) - (-PI.toFloat() / 4)).absoluteValue < epsilon}") // true
// atan(tan(x)) = x
println("(atan(tan(0.25f)) - 0.25f).absoluteValue < epsilon is ${(atan(tan(0.25f)) - 0.25f).absoluteValue < epsilon}") // true
// special cases
println(atan(Float.NaN)) // NaN
//sampleEnd
}
© 2010–2026 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.math/atan.html