Вычисление экспоненты числа в программировании на R - функция exp ()

Опубликовано: 18 Февраля, 2022

exp() function in R Language is used to calculate the power of e i.e. e^y or we can say exponential of y. The value of e is approximately equal to 2.71828…..

Syntax: exp(y)

Parameters:
y: It is any valid R number either positive or negative.

Returns: Floating point number by calculating e^y.

Пример 1:

# R program to calculate exp value 
    
# Using exp() method 
answer1 <- exp(4
answer2 <- exp(-3)  
answer3 <- exp(0.0)
  
print(answer1) 
print(answer2) 
print(answer3) 

Выход:

54,59815
0,04978707
1

Example 2:

# R program to calculate exp value 
    
# Using exp() method 
answer1 <- exp(c(pi, exp(1))) 
  
print(answer1)  

Выход:

23.14069 15.15426