util.math.exp

Shared

Returns e raised to the power of a number


Syntax

local result = util.math.exp(
    exponent
)

Parameters

TypeNameDescription
floatexponentPower to raise e to

Returns

TypeNameDescription
floatresulte raised to the given exponent (approximately 2.71828^exponent)

Examples

e to the power of 1
local result = util.math.exp(1)

core.engine.print("info", result) -- 2.718281828459
e to the power of 0
local result = util.math.exp(0)

core.engine.print("info", result) -- 1.0
e to the power of 2
local result = util.math.exp(2)

core.engine.print("info", result) -- 7.3890560989307
e to a negative power
local result = util.math.exp(-1)

core.engine.print("info", result) -- 0.36787944117144
Exponential decay formula
local initial = 100
local rate = 0.05
local time = 10
local remaining = initial*util.math.exp(-rate*time)

core.engine.print("info", remaining) -- 60.653065971263
Verify exp and log are inverses
local value = 3.5
local result = util.math.exp(util.math.log(value))

core.engine.print("info", result) -- 3.5

On this page