atan

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

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.2

Samples

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(source)

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.2

Samples

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
}
actual inline fun atan(x: Double): Double(source)

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.2

Samples

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(source)

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.2

Samples

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
}
actual inline fun atan(x: Double): Double(source)

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.2

Samples

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(source)

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.2

Samples

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
}
actual external fun atan(x: Double): Double(source)

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.3

Samples

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(source)

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.3

Samples

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
}
actual fun atan(x: Double): Double(source)

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.8

Samples

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 fun atan(x: Float): Float(source)

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.8

Samples

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
}
actual fun atan(x: Double): Double(source)

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.8

Samples

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 fun atan(x: Float): Float(source)

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

Special cases:

  • atan(NaN) is NaN

Since Kotlin

1.8

Samples

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
}