Ln()

From ElectronicWar

Jump to: navigation, search
Function information for ln()
Function ln()
Parameters (float)
API Challenge
Cost $0
Level N/A
CPU Usage 0
Description Returns the natural logarithm of the (float) parameter in the form of a float.


[edit] Example

If a challenge asked you to find the number of years of growth, respectively given the principal value, the rate of growth, and the resulting numbers, (after some handy algebra work) this would be the script:

float p = getInputFloat();
float r = getInputFloat();
float a = getInputFloat();
float y = 0.0;
float log = ln(a/p);
y = log/r;
setOutputFloat(y);

[edit] Algorithm Explanation

The ln of a number is the log base of e of that number

so ln5 = loge5.

This is used for exponential growth equations.

logbx = k

bk = x

That's the idea, but with ln, the logb is loge. One replaces loge with ln. ln and loge are exactly the same.

ln x = k

ek = x

The exponential growth equation:

A = Pey * r


A = Result number

P = Principal number

y = Number of years of growth

r = Rate of growth in percent

e ≈ 2.718 or use getE()

Personal tools