Kotlin kotlin.math.exp
The natural exponential turns a continuous growth exponent into a multiplier.
A simple example
kotlin.math.exp
- Start with 0
- Do this Raise e to the power 0
- Result 1
fun main() {
println(kotlin.math.exp(0.0))
}
1.0
Syntax
kotlin.math.exp(rate)
Run these examples in Kotlin
Save one example at a time as Lesson.kt. Use Kotlin 2.2 on JDK 21.
kotlinc Lesson.kt -include-runtime -d lesson.jar
java -jar lesson.jarCheck the baseline of a growth model
A growth simulator starts at zero elapsed change. Evaluate its baseline to determine what multiplier should preserve the initial population before any growth has occurred.
fun main() {
val rate = 0.0
System.out.printf(java.util.Locale.ROOT, "%.3f%n", (kotlin.math.exp(rate)).toDouble())
}
1.000
A zero exponent produces a multiplier of one, so an initial population remains the same.
Project a continuous growth multiplier
A class is comparing growth against an unchanged starting amount. Examine the multiplier at the reference point so a later increase can be interpreted relative to the original quantity.
fun main() {
val exponent = 1.0
System.out.printf(java.util.Locale.ROOT, "%.3f%n", (kotlin.math.exp(exponent)).toDouble())
}
2.718
A unit exponent corresponds to a multiplier near 2.718. Multiply the initial level by this factor.
Model a cooling signal
A normalized sensor model has a decay exponent of minus one over a test interval. The instrument needs the fraction of its original signal remaining.
Using -1 gives 0.368 × for this measurement.
What to watch for
The exponent is dimensionless. Convert rates and time to matching units first.