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.

Figure 1: 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 number
a <- exp(10);
print("exp(10): ")
print (a)
#negative number
b <- exp(-2);
print("exp(-2): ")
print (b)
#zero
c <- exp(0);
print("exp(0): ")
print (c)
#vector
d <- exp(c(1, -2, 10.4, -7.4))
print("exp(c(1, -2, 10.4, -7.4)): ")
print (d)

Free Resources