{"id":25385,"date":"2021-11-10T09:38:38","date_gmt":"2021-11-10T04:08:38","guid":{"rendered":"https:\/\/python-programs.com\/?p=25385"},"modified":"2021-11-10T09:38:38","modified_gmt":"2021-11-10T04:08:38","slug":"python-math-erfc-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-math-erfc-method-with-examples\/","title":{"rendered":"Python math.erfc() Method with Examples"},"content":{"rendered":"
math.erfc() Method in Python:<\/strong><\/p>\n The math.erfc() method returns a number’s complementary error function.<\/p>\n This method accepts values between – inf and + inf and returns between 0 and 2.<\/p>\n Syntax:<\/strong><\/p>\n Parameters<\/strong><\/p>\n x:<\/strong> This is Required. It is a number used to calculate the complementary error function of<\/p>\n Return Value:<\/strong><\/p>\n Returns a float value that represents a number’s complementary error function.<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Similarly, try for other numbers.<\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n math.erfc() Method in Python: The math.erfc() method returns a number’s complementary error function. This method accepts values between – inf and + inf and returns between 0 and 2. Syntax: math.erfc(x) Parameters x: This is Required. It is a number used to calculate the complementary error function of Return Value: Returns a float value that …<\/p>\nmath.erfc(x)<\/pre>\n
Given Number = 0.35<\/pre>\n
The given number's { 0.35 } complementary error function = 0.6206179464376897<\/pre>\n
Given Number = -5.6<\/pre>\n
The given number's { -5.6 } complementary error function = 1.9999999999999976<\/pre>\n
math.erfc() Method with Examples in Python<\/h2>\n
\n
Method #1: Using Built-in Functions (Static Input)<\/h3>\n
\n
# Import math module using the import keyword\r\nimport math\r\n# Give the number as static input and store it in a variable.\r\ngvn_numb = 0.35\r\n# Pass the given number as an argument to the math.erfc() function to get\r\n# the given number's complementary error function.\r\n# Store it in another variable.\r\nrslt = math.erfc(gvn_numb)\r\n# Print the complementary error function of the given number.\r\nprint(\"The given number's {\", gvn_numb,\r\n \"} complementary error function = \", rslt)\r\n<\/pre>\n
The given number's { 0.35 } complementary error function = 0.6206179464376897<\/pre>\n
import math\r\ngvn_numb = -1\r\nrslt = math.erfc(gvn_numb)\r\nprint(\"The given number's {\", gvn_numb,\r\n \"} complementary error function = \", rslt)\r\n<\/pre>\n
The given number's { -1 } complementary error function = 1.842700792949715<\/pre>\n
Method #2: Using Built-in Functions (User Input)<\/h3>\n
\n
# Import math module using the import keyword\r\nimport math\r\n# Give the number as user input using the float(input()) function and store it in a variable.\r\ngvn_numb = float(input(\"Enter some random number = \"))\r\n# Pass the given number as an argument to the math.erfc() function to get\r\n# the given number's complementary error function.\r\n# Store it in another variable.\r\nrslt = math.erfc(gvn_numb)\r\n# Print the complementary error function of the given number.\r\nprint(\"The given number's {\", gvn_numb,\r\n \"} complementary error function = \", rslt)\r\n<\/pre>\n
Enter some random number = -5.6\r\nThe given number's { -5.6 } complementary error function = 1.9999999999999976<\/pre>\n","protected":false},"excerpt":{"rendered":"