Trusted answers to developer questions

What is math.erf() in Python?

Free System Design Interview Course

Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.

Python is a high-level programming language that provides functionalities for a number of operations. The math module comes with mathematical methods and constraints, which make for straightforward calculations. math.erf() is used to print error functions for numbers. Error functions are used widely in statistical computations, machine learning, and a number of theoretical applications. It is defined as the integral of the normal distribution. There are a number of rules attached to this function:

  1. math.erf (-∞) = -1
  2. math.erf (+∞) = 1
  3. math.erf (-x) = -math.erf(x)
  4. math.erf (x*) = [math.erf (x)]*

Syntax

math.erf(x)

Parameters

  • x: The specified number of which to find the error function. Any positive or negative number is accepted. This parameter is required.

Return value

This method returns the error function of the specified number in the form of a float value between -1 and +1.

Code

#import library
import math
#display error functions for different values
print('Error function of 34 ==>',math.erf(34))
print('Error function of -10 ==>',math.erf(-10))
print('Error function of -0.98 ==>',math.erf(-0.98))
print('Error function of 5 ==>',math.erf(5))
print('Error function of 28.67 ==>',math.erf(28.67))
print('Error function of 100 ==>',math.erf(100))
print('Error function of -100 ==>',math.erf(-100))

RELATED TAGS

python
Did you find this helpful?