Ruby - Math.erfc() Method
The Ruby Math.erfc() method returns the complementary error function of the argument. The complementary error function of x is defined as:
Where, erf(x) is an error function. Error functions usually occur in probability, statistics and partial differential equation describing diffusion.
Syntax
Math.erfc(x)
Parameters
x |
Specify the value. |
Return Value
Returns the complementary error function of the argument.
Example:
In the example below, Math.erfc() method returns the complementary error function of the given value.
puts "Math.erfc(-2) = #{Math.erfc(-2)}" puts "Math.erfc(-1) = #{Math.erfc(-1)}" puts "Math.erfc(-0.5) = #{Math.erfc(-0.5)}" puts "Math.erfc(0) = #{Math.erfc(0)}" puts "Math.erfc(1) = #{Math.erfc(1)}" puts "Math.erfc(2) = #{Math.erfc(2)}"
The output of the above code will be:
Math.erfc(-2) = 1.9953222650189528 Math.erfc(-1) = 1.842700792949715 Math.erfc(-0.5) = 1.5204998778130465 Math.erfc(0) = 1.0 Math.erfc(1) = 0.15729920705028513 Math.erfc(2) = 0.004677734981047265
❮ Ruby Math Module