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 function returns the complementary error function.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

0.16576849565979213
1.7969082124228322
2.1519736712498916e-17
0.15729920705028513

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

0.3433722976996949
1.13475835181992
0.0006885138966450789
0.0

Reference: https://devdocs.io/ruby~2.5/math#method-c-erfc



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.