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 function.
Example 1:
# Ruby program for erf() function # Assigning values val1 = 0.98 val2 = -0.9 val3 = 6 val4 = 1 # Prints the erf() value puts Math.erf(val1) puts Math.erf(val2) puts Math.erf(val3) puts Math.erf(val4) |
Output:
0.8342315043402079 -0.7969082124228322 1.0 0.8427007929497149
Example 2:
# Ruby program for erf() function # Assigning values val1 = 0.67 val2 = -0.12 val3 = 2.4 val4 = 89 # Prints the erf() value puts Math.erf(val1) puts Math.erf(val2) puts Math.erf(val3) puts Math.erf(val4) |
Output:
0.6566277023003051 -0.13475835181992007 0.999311486103355 1.0
Reference: https://devdocs.io/ruby~2.5/math#method-c-erf
Recommended Posts:
- Ruby | Math log() function
- Ruby | Math exp() function
- Ruby | Math sin() function
- Ruby | Math cos() function
- Ruby | Math tan() function
- Ruby | Math cosh() function
- Ruby | Math frexp() function
- Ruby | Math log10() function
- Ruby | Math lgamma() function
- Ruby | Math atan() function
- Ruby | Math erfc() function
- Ruby | Math hypot() function
- Ruby | Math log2() function
- Ruby | Math ldexp() function
- Ruby | Math atan2() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

