math.exp
Shared
Returns e raised to the power of a number
Syntax
local result = math.exp(
exponent
)Parameters
| Type | Name | Description |
|---|---|---|
number | exponent | Power to raise e to |
Returns
| Type | Name | Description |
|---|---|---|
number | result | e raised to the given exponent (approximately 2.71828^exponent) |
Examples
local result = math.exp(1)
engine.print("info", result) -- 2.718281828459local result = math.exp(0)
engine.print("info", result) -- 1.0local result = math.exp(2)
engine.print("info", result) -- 7.3890560989307local result = math.exp(-1)
engine.print("info", result) -- 0.36787944117144local initial = 100
local rate = 0.05
local time = 10
local remaining = initial * math.exp(-rate * time)
engine.print("info", remaining) -- 60.653065971263local value = 3.5
local result = math.exp(math.log(value))
engine.print("info", result) -- 3.5