Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

r
math
exponent
communitycreator

# How to calculate the natural exponential in R using exp()

harris910

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)

RELATED TAGS

r
math
exponent
communitycreator

CONTRIBUTOR

harris910
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time