| FazBrowse Wikipedia Viewer | Main Page | | |
| Viewing: https://en.wikipedia.org/wiki/Error_function |
| Contents |
|---|
| Name |
| Taylor series |
| Table of values |
| Related functions |
| Complementary error function |
| Imaginary error function |
| References |
| Error function | |
|---|---|
Plot of the error function over real numbers | |
| General information | |
| General definition | ℂ |
| Basic features | |
| Parity | Odd |
| Specific features | |
| Root | 0 |
| Derivative | erf(z)=2π∑n=0∞(−1)nz2n+1n!(2n+1)=2π(z−z33+z510−z742+z9216⋯) |
In mathematics, the error function (also called the Gauss error function), often denoted by exp(−t2) is holomorphic on the whole complex plane X, the error function has the following interpretation: for a real random variable erf(x) is the probability that erfc(z)=1−erf(z)
and the imaginary error function
The name "error function" and its abbreviation p and σ and expected value zero, then
The error and complementary error functions occur, for example, in solutions of the heat equation when boundary conditions are given by the Heaviside step function.
The error function and its approximations can be used to estimate results that hold with high probability or with low probability. Given a normally distributed random variable σ and a constant \\mu"}}'>L>μ, it can be shown via integration by substitution that
and so the probability goes to 0 as [La,Lb] can be derived as e−t2 is an even function (since the antiderivative of an even function which is zero at the origin is an odd function, and vice versa).
Since the error function is an entire function which maps real numbers to real numbers, for any complex number z¯ denotes the complex conjugate of 1 (see Gaussian integral). At the real axis, z→∞ and ±i∞.
The error function is an entire function; it has no singularities (except at infinity) and its Taylor expansion always converges. For erf(0)=0, one obtains the error function's Maclaurin series as: −(2k−1)z2k(2k+1)
expresses the multiplier to turn the z as the first term).
The imaginary error function has a similar Maclaurin series: ddzerf(z)=2πe−z2. From this, the derivative of the imaginary error function is also immediate: Hk are the physicists' Hermite polynomials.
An antiderivative of the error function, obtainable by integration by parts, is x than a Taylor expansion is obtained by using Bürmann's theorem: c1=31/200 and 0.0034361: w satisfying erf−1(x) satisfying
So we have the series expansion (common factors have been canceled from numerators and denominators):
For erfc−1(1−z)=erf−1(z). For real erfi(erfi−1(x))=x. The inverse imaginary error function is defined as erfi−1(z)=∑k=0∞(−1)kck2k+1(π2z)2k+1,
where erfc(x)=e−x2xπ(1+∑n=1∞(−1)n1⋅3⋅5⋯(2n−1)(2x2)n)=e−x2xπ∑n=0∞(−1)n(2n−1)!!(2x2)n, where 2n−1. This series diverges for every finite erfc(x)=e−x2xπ∑n=0N−1(−1)n(2n−1)!!(2x2)n+RN(x),
where the remainder is
as x, only the first few terms of this asymptotic expansion are needed to obtain a good approximation of erfc(z)=zπe−z21z2+a11+a2z2+a31+⋯ where Re(z2)>0. Here
where a2 = −0.0958798, 3</sub> {{=}} 0.7478556"}},"i":0}}]}'>a3 = 0.7478556
where 1</sub> {{=}} 0.0705230784"}},"i":0}}]}'>a1 = 0.0705230784, 2</sub> {{=}} 0.0422820123"}},"i":0}}]}'>a2 = 0.0422820123, 3</sub> {{=}} 0.0092705272"}},"i":0}}]}'>a3 = 0.0092705272, 4</sub> {{=}} 0.0001520143"}},"i":0}}]}'>a4 = 0.0001520143, 5</sub> {{=}} 0.0002765672"}},"i":0}}]}'>a5 = 0.0002765672, 6</sub> {{=}} 0.0000430638"}},"i":0}}]}'>a6 = 0.0000430638
where a2 = −0.284496736, 3</sub> {{=}} 1.421413741"}},"i":0}}]}'>a3 = 1.421413741, 4</sub> {{=}} −1.453152027"}},"i":0}}]}'>a4 = −1.453152027, 5</sub> {{=}} 1.061405429"}},"i":0}}]}'>a5 = 1.061405429
Python code to fit extended A&S approximation |
|---|
|
7 in total\na0 = [\n 0.254829592,\n -0.284496736,\n 1.421413741,\n -1.453152027,\n 1.061405429,\n 0.0, # new term\n 0.0, # another new term\n]\n\nparams0 = np.array([p1_0, p2_0] + a0, dtype=float)\n\n#\n# Fit using nonlinear least squares (Levenberg–Marquardt)\n#\n\nresult = least_squares(\n residuals, params0, args=(xs, ys), xtol=1e-14, ftol=1e-14, gtol=1e-14, max_nfev=5000\n)\n\nparams = result.x\np1_fit = params[0]\np2_fit = params[1]\na_fit = params[2:]\n\n#\n# Print fitted parameters\n#\n\nprint(\"\\nFitted parameters:\")\nprint(f\"p1 = {p1_fit:.15g},\")\nprint(f\"p2 = {p2_fit:.15g},\")\nfor i, ai in enumerate(a_fit, 1):\n print(f\"a{i} = {ai:.15g},\")\n\n#\n# Evaluate approximation error\n#\n\napprox_vals = approx_erf(params, xs)\nabs_err = np.abs(approx_vals - ys)\n\nprint(f\"\\nMaximum absolute error on [{xmin},{xmax}]:\", np.max(abs_err))\nprint(\"RMS error:\", np.sqrt(np.mean(abs_err**2)))\nprint(\"Done.\")\n"}}'>importnumpyasnp
frommathimport erf, exp, sqrt
fromscipy.optimizeimport least_squares
#
# Extended A&S approximation:
# erf(x) ≈ 1 − t * exp(−x^2) * (a1 + a2*t + a3*t^2 + ... + a7*t^6)
# where now
# t = 1 / (1 + p1*x + p2*x^2)
# We fit parameters p1, p2, a1..a7 over x in [0, 10].
#
defapprox_erf(params, x):
p1 = params[0]
p2 = params[1]
a = params[2:]
t = 1.0 / (1.0 + p1 * x + p2 * x * x)
poly = np.zeros_like(x)
tt = np.ones_like(x) # t^0
# polynomial: a1*t^0 + a2*t^1 + ... + a7*t^6
for ak in a:
poly += ak * tt
tt *= t
return 1.0 - t * np.exp(-x * x) * poly
defresiduals(params, xs, ys):
return approx_erf(params, xs) - ys
#
# Prepare data for fitting
#
N = 300
xmin = 0
xmax = 10
xs = np.linspace(xmin, xmax, N)
ys = np.array([erf(x) for x in xs], dtype=float)
#
# Initial guess for parameters
# Start from original A&S values and extend them conservatively
#
p1_0 = 0.3275911 # original A&S p
p2_0 = 0.0 # new denominator parameter
# original A&S 5 coefficients, add two => 7 in total
a0 = [
0.254829592,
-0.284496736,
1.421413741,
-1.453152027,
1.061405429,
0.0, # new term
0.0, # another new term
]
params0 = np.array([p1_0, p2_0] + a0, dtype=float)
#
# Fit using nonlinear least squares (Levenberg–Marquardt)
#
result = least_squares(
residuals, params0, args=(xs, ys), xtol=1e-14, ftol=1e-14, gtol=1e-14, max_nfev=5000
)
params = result.x
p1_fit = params[0]
p2_fit = params[1]
a_fit = params[2:]
#
# Print fitted parameters
#
print("\nFitted parameters:")
print(f"p1 = {p1_fit:.15g},")
print(f"p2 = {p2_fit:.15g},")
for i, ai in enumerate(a_fit, 1):
print(f"a{i} = {ai:.15g},")
#
# Evaluate approximation error
#
approx_vals = approx_erf(params, xs)
abs_err = np.abs(approx_vals - ys)
print(f"\nMaximum absolute error on [{xmin},{xmax}]:", np.max(abs_err))
print("RMS error:", np.sqrt(np.mean(abs_err**2)))
print("Done.")
|
All of these approximations are valid for erf(x) is an odd function, so N exponentials with increasing accuracy in terms of 2Q̃(√2x), where
Q(x) ≈ Q̃(x), x ≥ 0. The coefficients n</sub>'',''b<sub>n</sub>'')}{{su|b=''n'' {{=}} 1|p=''N''}}"}},"i":0}}]}'>{(an,bn)}
n = 1 for many variations of the exponential approximations and bounds up to {A,B} that
for all β can be picked to minimize error on the desired interval of approximation.
Another approximation is given by Sergei Winitzki using his "global Padé approximations": x. Using the alternate value The extended "global Pade" approximation, importnumpy,math fromscipy.optimizeimport least_squares # approximation to erf(x) defapprox_erf(p,x): frac=(4+p[0]*x**2+p[1]*x**4+p[2]*x**6)/( math.pi+p[3]*x**2+p[4]*x**4+p[5]*x**6) return numpy.sign(x)*numpy.sqrt( 1-numpy.exp(-x*x*frac)) defresiduals(params, xs, ys): return approx_erf(params, xs) - ys # data for fitting N = 200 xmin = 0 xmax = 9 xs = numpy.linspace(xmin, xmax, N) ys = numpy.array([math.erf(x) for x in xs], dtype=float) params0 = numpy.array([0.9,0.1,0.008,0.8,0.1,0.008], dtype=float) # fitting result = least_squares( residuals, params0, args=(xs, ys), xtol=1e-14, ftol=1e-14, gtol=1e-14, max_nfev=5000 ) params = result.x # print out fitted parameters print("\nFitted parameters:") for i, pi in enumerate(params, 0): print(f"p{i} = {pi:.15g},") # evaluate approximation error approx_vals = approx_erf(params, xs) abs_err = numpy.abs(approx_vals - ys) print(f"\nMaximum absolute error on [{xmin},{xmax}]:", numpy.max(abs_err)) print("RMS error:", numpy.sqrt(numpy.mean(abs_err**2))) print("Done.")
Winitzki's approximation can be inverted to obtain an approximation for the inverse error function: erf(x)={1−τ,x≥0τ−1,x<0τ=t⋅exp(−x2−1.26551223+1.00002368t+0.37409196t2+0.09678418t3−0.18628806t4+0.27886807t5−1.13520398t6+1.48851587t7−0.82215223t8+0.17087277t9)t=11+12|x|
An approximation of (≈1.1×10−16) in absolute value is: for x\\ge 0</math>,"}},"i":0}}]}'>x<0 Q(x)=12erfc(x2), bounds developed for the Q-function can be adapted to approximate the complementary error function. A pair of tight lower and upper bounds on the Gaussian Q-function for positive arguments QB(x;a,b)=exp(−x2)a+exp(−x2/2)b(x+1), where the parameters aL=12 and bU=2. These expressions maintain simplicity and tightness, providing a practical trade-off between accuracy and ease of computation. They are particularly valuable in theoretical contexts, such as communication theory over fading channels, where both functions frequently appear. Additionally, the original Q-function bounds can be extended to erfc(x), though this is less commonly required in error function applications.
Despite the name "imaginary error function", z, the resulting complex error function is usually discussed in scaled form as the Faddeeva function: norm(x) by some software languageserf and Q(x)=12−12erf(x2)=12erfc(x2).
The inverse of P and the incomplete gamma function, inerfc(z)=∫z∞in−1erfc(ζ)dζi0erfc(z)=erfc(z)i1erfc(z)=ierfc(z)=1πe−z2−zerfc(z)i2erfc(z)=14(erfc(z)−2zierfc(z))
The general recurrence formula is i2merfc(−z)=−i2merfc(z)+∑q=0mz2q22(m−q)−1(2q)!(m−q)! and Weisstein, Eric W. "Erf". MathWorld.
| View original on Wikipedia | Back | FazBrowse Home |