Friday, June 22, 2018

How is the exponential function handled in R?

Exponential functions are very important in all branches of physics and mathematics. It is in fact taught in the very beginning when one learns mathematics.

In R programming exp(x) calculates,  'e to the power of x' where e is the Euler's constant.

Let us calculate the values of e raised to power of x, for x=0, 1, 10, and 100 using R.


How about exponential of negative numbers like, e raised to power of y, where y=-1,-10, and -100?

R can also be used to find expm1() which is defined as follows and should be used for small values of x instead of exp():

expm1(x)=exp(x)-1=(2*tanh(x/2))/(1-tanh(x/2))


For small x expm1() is better than exp() - 1



No comments: