expm1
Computes exp(x) - 1.
This function can be implemented to produce more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.2See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Double.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17) - 1.0) // 0.0
println(expm1(1e-17)) // 1e-17.toString()
// special cases
println(expm1(Double.NaN)) // NaN
println(expm1(Double.POSITIVE_INFINITY)) // Infinity
println(expm1(Double.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}Computes exp(x) - 1.
This function can be implemented to produce a more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.2See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Float.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0f).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17f) - 1.0f) // 0.0
println(expm1(1e-17f)) // 1e-17f.toString()
// special cases
println(expm1(Float.NaN)) // NaN
println(expm1(Float.POSITIVE_INFINITY)) // Infinity
println(expm1(Float.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}Computes exp(x) - 1.
This function can be implemented to produce more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.2See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Double.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17) - 1.0) // 0.0
println(expm1(1e-17)) // 1e-17.toString()
// special cases
println(expm1(Double.NaN)) // NaN
println(expm1(Double.POSITIVE_INFINITY)) // Infinity
println(expm1(Double.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}Computes exp(x) - 1.
This function can be implemented to produce more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.2See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Float.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0f).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17f) - 1.0f) // 0.0
println(expm1(1e-17f)) // 1e-17f.toString()
// special cases
println(expm1(Float.NaN)) // NaN
println(expm1(Float.POSITIVE_INFINITY)) // Infinity
println(expm1(Float.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}Computes exp(x) - 1.
This function can be implemented to produce more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.2See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Double.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17) - 1.0) // 0.0
println(expm1(1e-17)) // 1e-17.toString()
// special cases
println(expm1(Double.NaN)) // NaN
println(expm1(Double.POSITIVE_INFINITY)) // Infinity
println(expm1(Double.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}Computes exp(x) - 1.
This function can be implemented to produce more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.2See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Float.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0f).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17f) - 1.0f) // 0.0
println(expm1(1e-17f)) // 1e-17f.toString()
// special cases
println(expm1(Float.NaN)) // NaN
println(expm1(Float.POSITIVE_INFINITY)) // Infinity
println(expm1(Float.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}Computes exp(x) - 1.
This function can be implemented to produce more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.3See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Double.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17) - 1.0) // 0.0
println(expm1(1e-17)) // 1e-17.toString()
// special cases
println(expm1(Double.NaN)) // NaN
println(expm1(Double.POSITIVE_INFINITY)) // Infinity
println(expm1(Double.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}Computes exp(x) - 1.
This function can be implemented to produce more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.3See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Float.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0f).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17f) - 1.0f) // 0.0
println(expm1(1e-17f)) // 1e-17f.toString()
// special cases
println(expm1(Float.NaN)) // NaN
println(expm1(Float.POSITIVE_INFINITY)) // Infinity
println(expm1(Float.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}Computes exp(x) - 1.
This function can be implemented to produce more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.8See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Double.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17) - 1.0) // 0.0
println(expm1(1e-17)) // 1e-17.toString()
// special cases
println(expm1(Double.NaN)) // NaN
println(expm1(Double.POSITIVE_INFINITY)) // Infinity
println(expm1(Double.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}Computes exp(x) - 1.
This function can be implemented to produce more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.8See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Float.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0f).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17f) - 1.0f) // 0.0
println(expm1(1e-17f)) // 1e-17f.toString()
// special cases
println(expm1(Float.NaN)) // NaN
println(expm1(Float.POSITIVE_INFINITY)) // Infinity
println(expm1(Float.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}Computes exp(x) - 1.
This function can be implemented to produce more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.8See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Double.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17) - 1.0) // 0.0
println(expm1(1e-17)) // 1e-17.toString()
// special cases
println(expm1(Double.NaN)) // NaN
println(expm1(Double.POSITIVE_INFINITY)) // Infinity
println(expm1(Double.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}Computes exp(x) - 1.
This function can be implemented to produce more precise result for x near zero.
Special cases:
expm1(NaN)isNaNexpm1(+Inf)is+Infexpm1(-Inf)is-1.0
Since Kotlin
1.8See also
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
fun Float.firstFiveDigits(): String = toString().substring(0, 7)
println(expm1(1.0f).firstFiveDigits()) // 1.71828
// While it does not really matter for relatively large x values (like 1.0),
// the difference is getting more pronounced when x is getting closer to 0.0
println(exp(1e-17f) - 1.0f) // 0.0
println(expm1(1e-17f)) // 1e-17f.toString()
// special cases
println(expm1(Float.NaN)) // NaN
println(expm1(Float.POSITIVE_INFINITY)) // Infinity
println(expm1(Float.NEGATIVE_INFINITY)) // -1.0
//sampleEnd
}