Ruby | Math erfc() function Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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 function returns the complementary error function. Example 1: CPP # Ruby program for erfc() function # Assigning values val1 = 0.98 val2 = -0.9 val3 = 6 val4 = 1 # Prints the erfc() value puts Math.erfc(val1) puts Math.erfc(val2) puts Math.erfc(val3) puts Math.erfc(val4) Output: 0.16576849565979213 1.7969082124228322 2.1519736712498916e-17 0.15729920705028513 Example 2: CPP # Ruby program for erfc() function # Assigning values val1 = 0.67 val2 = -0.12 val3 = 2.4 val4 = 89 # Prints the erfc() value puts Math.erfc(val1) puts Math.erfc(val2) puts Math.erfc(val3) puts Math.erfc(val4) Output: 0.3433722976996949 1.13475835181992 0.0006885138966450789 0.0 Reference: https://devdocs.io/ruby~2.5/math#method-c-erfc Comment More infoAdvertise with us Next Article Ruby | Math frexp() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Math-class Similar Reads 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 exp() function 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^valu 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 log() function The log() function in Ruby returns the logarithm value of X. The second parameter is the base given by the user to which the logarithm value is returned. In case its not given, then the default base is e. Syntax: Math.log(X, base) Parameter: The function takes one mandatory parameter X whose logarit 1 min read Ruby | Math log2() function The log2() function in Ruby returns the base 2 logarithm value of X. Syntax: Math.log2(X) Parameter: The function takes one mandatory parameter X whose base 2 logarithm value is to be returned. Return Value: The function the base 2 logarithm value of X. Example 1: CPP # Ruby program for log2() funct 1 min read Ruby | Math sqrt() function The sqrt() is an inbuilt function in Ruby returns the square root of a given value. Syntax: Math.sqrt(value) Parameters: The function accepts one mandatory parameter value whose square root is to be returned. Return Value: It returns the square root of the value. Example 1: CPP #Ruby program for sqr 1 min read Like