[ Web Proxy ]
URL:
Viewing: https://www.tutorialspoint.com/python/python_math_erf_method.htm [Back]  [Original]

Python math.erf() Method
Tutorials Courses Jobs Login
Selected Reading
Home Python Python math.erf() Method

Python math.erf() Method



The Python math.erf() method is used to calculate the error method. It is a mathematical method that describes the probability of an event occurring within a certain range of values in a normal distribution.

Mathematically, the error method is defined as

$$\mathrm{erf(x)\:=\:\frac{2}{\sqrt{\pi}}\:\int^{x}_{0}\:e^{t^{2}}\:dt}$$

Where, e is the base of the natural logarithm and is the mathematical constant pi. The error method is an odd method, meaning that erf(-x) = -erf(x) and is being bounded between -1 and 1.

Syntax

Following is the basic syntax of the Python math.erf() method

math.erf(x)

Parameters

This method accepts a real number or a numeric expression as a parameter for which you want to calculate the error method.

Return Value

The method returns the value of the error method evaluated at x.

Example 1

In the following example, we are calculating the error method for a positive real number using the math.erf() method

import math
x = 1.5
result = math.erf(x)
print("Error method for x =", x, ":", result)

Output

The output obtained is as follows

Error method for x = 1.5 : 0.9661051464753108

Example 2

In here, we are calculating the error method for a negative real number using the math.erf() method

import math
x = -0.75
result = math.erf(x)
print("Error method for x =", x, ":", result)

Output

Following is the output of the above code

Error method for x = -0.75 : -0.7111556336535151

Example 3

In this example, we are evaluating the sum of error methods for x=2 and x/2 using the math.erf() method

import math
x = 2
result = math.erf(x) + math.erf(x/2)
print("Error method expression result for x =", x, ":", result) 

Output

We get the output as shown below

Error method expression result for x = 2 : 1.8380230579686676

Example 4

Now, we use the math.erf() method to directly calculate the error method for x=0

import math
x = 0
result = math.erf(x)
print("Error method for x =", x, ":", result)

Output

The result produced is as shown below

Error method for x = 0 : 0.0
python_maths.htm
Tutorix - AI Tutor [Tutorix - AI Tutor]
Print Page
Advertisements

Web Proxy Viewer  |  New URL  |  Original Page