Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

ruby
math
exp
communitycreator

What is Math.exp() in Ruby?

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The exp() function in Ruby returns the mathematical e raised to the power of a specific number. Here, e is the base of the natural logarithm. Figure 1 shows the mathematical representation of the exp() function.

Figure 1: Mathematical representation of the exp() function

Syntax

exp(number)

Parameter

This function requires a number as a parameter.

Return value

exp() returns the mathematical e raised to the power of the specific number sent as a parameter.

Example

#positive number
print "exp(10) : ", Math.exp(10), "\n"
#negative number
print "exp(-2) : ", Math.exp(-2), "\n"
#zero
print "exp(0) : ", Math.exp(0), "\n"

RELATED TAGS

ruby
math
exp
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring