# R - exp() Function

The R exp() function returns e raised to the power of specified number, i.e., ex. Please note that e is the base of the natural system of logarithms, and its value is approximately 2.718282. In special cases it returns the following:

• If the argument is NaN, the result is NaN.
• If the argument is positive infinity, then the result is positive infinity.
• If the argument is negative infinity, then the result is positive zero.

### Syntax

```exp(x)
```

### Parameters

 `x` `Required. `Specify column to compute on.

### Return Value

Returns e raised to the power of specified number.

### Example:

In the example below, exp() function is used to calculate e raised to the power of specified number.

```#operating on single element atomic vector
print(exp(0))
print(exp(0.5))
print(exp(1))

cat("\nOperating on vector\n")
#operating on vector
v <- c(4, 5, 6)
print(exp(v))

cat("\nOperating on matrix\n")
#operating on matrix
m <- matrix(c(1, 2, 3, 4, Inf, NaN), nrow=2)
print(exp(m))

cat("\nOperating on first column of matrix\n")
#operating on first column of matrix
print(exp(m[,1]))
```

The output of the above code will be:

``` 1
 1.648721
 2.718282

Operating on vector
  54.59815 148.41316 403.42879

Operating on matrix
[,1]     [,2] [,3]
[1,] 2.718282 20.08554  Inf
[2,] 7.389056 54.59815  NaN

Operating on first column of matrix
 2.718282 7.389056
```

❮ R Math Functions

5