How to calculate the natural exponential in R using exp()
The exp() function returns the mathematical e raised to the power of a specific number. Here, e is the base of the natural logarithm, also called the Euler’s number.
Figure 1 shows the mathematical representation of the exp() function.
Syntax
exp(number or vector)
Parameter
This function has a single parameter that takes any real number or a vector of real numbers.
Return value
exp() returns the mathematical e raised to the power of the specific number (or a vector) passed as an argument.
Code
#Positive numbera <- exp(10);print("exp(10): ")print (a)#negative numberb <- exp(-2);print("exp(-2): ")print (b)#zeroc <- exp(0);print("exp(0): ")print (c)#vectord <- exp(c(1, -2, 10.4, -7.4))print("exp(c(1, -2, 10.4, -7.4)): ")print (d)