R exp Function


exp(x) function compute the exponential value of a number or number vector, ex.

> x <- 5
> exp(x)
[1] 148.4132

> y <- rep(1:20)
> exp(y)
         [,1]     [,2]     [,3]     [,4]      [,5]
[1,] 2.718282 20.08554 148.4132 1096.633  8103.084
[2,] 7.389056 54.59815 403.4288 2980.958 22026.466

^ operator calculates a raised to power b:
> 2^3
[1] 8

> 4 ^ (1/2)
[1] 2

expm1() function computes exp() minus 1:
> expm1(5)
[1] 147.4132

> expm1(rep(1:20))
         [,1]     [,2]     [,3]     [,4]      [,5]
[1,] 1.718282 19.08554 147.4132 1095.633  8102.084
[2,] 6.389056 53.59815 402.4288 2979.958 22025.466

Let's plot the exponential value in the range of -1 ~ 5:
> plot(exp(c(-1,0,0.2,0.3,1,2,3,4,5)),col="darkgreen")