Ruby | Math exp() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The exp() function in Ruby returns the value of e^value. It takes value in range [-inf, +inf] and returns the answer in range [0, infinity]. Syntax: Math.exp(value) Parameter: The function takes the value which is to be raised to the power of e. Return Value: The function returns the value of e^value. Example 1: CPP # Ruby program for exp() function # Assigning values val1 = 0.98 val2 = -0.9 val3 = 6 val4 = 1 # Prints the exp() value puts Math.exp(val1) puts Math.exp(val2) puts Math.exp(val3) puts Math.exp(val4) Output: 2.664456241929417 0.4065696597405991 403.4287934927351 2.718281828459045 Example 2: CPP # Ruby program for exp() function # Assigning values val1 = 0.67 val2 = -0.12 val3 = 2.4 val4 = 89 # Prints the exp() value puts Math.exp(val1) puts Math.exp(val2) puts Math.exp(val3) puts Math.exp(val4) Output: 1.9542373206359396 0.8869204367171575 11.023176380641601 4.4896128191743455e+38 Reference: https://devdocs.io/ruby~2.5/math#method-c-exp Comment More infoAdvertise with us Next Article Ruby | Math erfc() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Math-class Similar Reads Ruby | Math frexp() function The frexp() function in Ruby returns a two-element array containing the normalized fraction which is a float value and an exponent that is an integer value of the given number. On equating, fraction ** (2 ^ exponent) gives back the number. Syntax: Math.frexp(number) Parameter: The function takes a m 1 min read Ruby | Math frexp() function The frexp() function in Ruby returns a two-element array containing the normalized fraction which is a float value and an exponent that is an integer value of the given number. On equating, fraction ** (2 ^ exponent) gives back the number. Syntax: Math.frexp(number) Parameter: The function takes a m 1 min read Ruby | Math erf() function The erf() function in Ruby returns the error function of x. It accepts value in the range [-inf, +inf] and returns value in the range [-1, +1]. Syntax: Math.erf(value) Parameter: The function takes the value whose error function is to be returned. Return Value: The function returns the error functio 1 min read Ruby | Math erf() function The erf() function in Ruby returns the error function of x. It accepts value in the range [-inf, +inf] and returns value in the range [-1, +1]. Syntax: Math.erf(value) Parameter: The function takes the value whose error function is to be returned. Return Value: The function returns the error functio 1 min read Ruby | Math erfc() function The erfc() function in Ruby returns the complementary error function of x. It accepts value in the range [-inf, +inf] and returns value in the range [0, 2]. Syntax: Math.erfc(value) Parameter: The function takes the value whose complementary error function is to be returned. Return Value: The functi 1 min read Ruby | Math erfc() function The erfc() function in Ruby returns the complementary error function of x. It accepts value in the range [-inf, +inf] and returns value in the range [0, 2]. Syntax: Math.erfc(value) Parameter: The function takes the value whose complementary error function is to be returned. Return Value: The functi 1 min read Like