To create an exponential function, you let the independent variable be the exponent. Exponential functions are solutions to the simplest types of dynamical systems.
The Natural Exponential Function equation is the following.
Where e is “Eulers Number” = 2.718281828459
An exponential function can describe growth or decay. The exponential decay function can be described as the following.
R exp() Function
The exp() is an inbuilt R mathematical function that calculates the exponential value of a number or number vector, e^x. The value of e is approximately equal to 2.71828.
x: It is any valid R number, either positive or negative.
The return value is a floating-point number by calculating e^x.
Let’s define three numerical values, including floating-point, integer, and double value.
data <- 1 info <- -2 stock <- 1.9 exp(data) exp(info) exp(stock)
 2.718282  0.1353353  6.685894
Calculate the exponential value of pi in R
The pi is an inbuilt constant in R. Let’s calculate the exponential value of pi.
Let’s plot the line chart from -pi to +pi.
y <- seq(-pi, pi, by = 0.1) plot(y, exp(y), typ = "l", col = "green")
Calculate the exponential value of a Vector in R
You can define a vector using ( : ) colon operator. To calculate the exponential value of a vector, pass the vector as an argument to the exp() function.
data <- rep(1:5) exp(data)
 2.718282 7.389056 20.085537 54.598150 148.413159
Plot the exponential value in the range of -4 ~ +4
To plot the exponential value in R, use the plot() function.
y <- seq(-4, 4, by = 0.1) plot(y, exp(y), typ = "l", col = "green")
You can see that the value is increasing exponentially, and you can clearly see the exponent growth in the line chart.
That is it for exp() function in R language.