Error and Complementary Error Functions Outline
Total Page:16
File Type:pdf, Size:1020Kb
Error and Complementary Error Functions Reading Problems Outline Background ...................................................................2 Definitions .....................................................................4 Theory .........................................................................6 Gaussian function .......................................................6 Error function ...........................................................8 Complementary Error function .......................................10 Relations and Selected Values of Error Functions ........................12 Numerical Computation of Error Functions ..............................19 Rationale Approximations of Error Functions ............................21 Assigned Problems ..........................................................23 References ....................................................................27 1 Background The error function and the complementary error function are important special functions which appear in the solutions of diffusion problems in heat, mass and momentum transfer, probability theory, the theory of errors and various branches of mathematical physics. It is interesting to note that there is a direct connection between the error function and the Gaussian function and the normalized Gaussian function that we know as the \bell curve". The Gaussian function is given as G(x) = Ae−x2=(2σ2) where σ is the standard deviation and A is a constant. The Gaussian function can be normalized so that the accumulated area under the curve is unity, i.e. the integral from −∞ to +1 equals 1. If we note that the definite integral Z 1 rπ e−ax2 dx = −∞ a then the normalized Gaussian function takes the form 1 2 2 G(x) = p e−x =(2σ ) 2πσ If we let x2 1 t2 = and dt = p dx 2σ2 2σ then the normalized Gaussian integrated between −x and +x can be written as x x Z 1 Z 2 G(x) dx = p e−t dt −x π −x or recognizing that the normalized Gaussian is symmetric about the y−axis, we can write 2 x x Z 2 Z 2 x G(x) dx = p e−t dt = erf x = erf p −x π 0 2σ and the complementary error function can be written as 1 2 Z 2 erfc x = 1 − erf x = p e−t dt π x Historical Perspective The normal distribution was first introduced by de Moivre in an article in 1733 (reprinted in the second edition of his Doctrine of Chances, 1738 ) in the context of approximating certain binomial distributions for large n. His result was extended by Laplace in his book Analytical Theory of Probabilities (1812 ), and is now called the Theorem of de Moivre-Laplace. Laplace used the normal distribution in the analysis of errors of experiments. The important method of least squares was introduced by Legendre in 1805. Gauss, who claimed to have used the method since 1794, justified it in 1809 by assuming a normal distribution of the errors. The name bell curve goes back to Jouffret who used the term bell surface in 1872 for a bivariate normal with independent components. The name normal distribution was coined independently by Charles S. Peirce, Francis Galton and Wilhelm Lexis around 1875 [Stigler]. This terminology is unfortunate, since it reflects and encourages the fallacy that \everything is Gaussian". 3 Definitions 1. Gaussian Function The normalized Gaussian curve represents the probability distribution with standard distribution σ and mean µ relative to the average of a random distribution. 1 2 2 G(x) = p e−(x−µ) =(2σ ) 2πσ This is the curve we typically refer to as the \bell curve" where the mean is zero and the standard distribution is unity. 2. Error Function The error functionp equals twice the integral of a normalized Gaussian function between 0 and x/σ 2. x 2 Z 2 y = erf x = p e−t dt for x ≥ 0; y [0; 1] π 0 where x t = p 2 σ 3. Complementary Error Function The complementary error function equals one minus the error function 1 2 Z 2 1 − y = erfc x = 1 − erf x = p e−t dt for x ≥ 0; y [0; 1] π x 4. Inverse Error Function x = inerf y inerf y exists for y in the range −1 < y < 1 and is an odd function of y with a Maclaurin expansion of the form 4 1 X 2n−1 inverf y = cn y n=1 5. Inverse Complementary Error Function x = inerfc (1 − y) 5 Theory Gaussian Function The Gaussian function or the Gaussian probability distribution is one of the most fundamen- tal functions. The Gaussian probability distribution with mean µ and standard deviation σ is a normalized Gaussian function of the form 1 2 2 G(x) = p e−(x−µ) =(2σ ) (1.1) 2πσ where G(x), as shown in the plot below, gives the probability that a variate with a Gaussian distribution takes on a value in the range [x; x + dx]. Statisticians commonly call this distribution the normal distribution and, because of its shape, social scientists refer to it as the \bell curve." G(x) has been normalized so that the accumulated area under the curve between −∞ ≤ x ≤ +1 totals to unity. A cumulative distribution function, which totals the area under the normalized distribution curve is available and can be plotted as shown below. GHxL DHxL x x -4 -2 2 4 -4 -2 2 4 Figure 2.1: Plot of Gaussian Function and Cumulative Distribution Function When the mean is set to zero (µ = 0) and the standard deviation or variance is set to unity (σ = 1), we get the familiar normal distribution 1 2 G(x) = p e−x =2dx (1.2) 2π which is shown in the curve below. The normal distribution function N(x) gives the prob- ability that a variate assumes a value in the interval [0; x] x 1 Z 2 N(x) = p e−t =2 dt (1.3) 2π 0 6 NHxL 0.4 0.3 0.2 0.1 x -4 -2 2 4 Figure 2.2: Plot of the Normalized Gaussian Function Gaussian distributions have many convenient properties, so random variates with unknown distributions are often assumed to be Gaussian, especially in physics, astronomy and various aspects of engineering. Many common attributes such as test scores, height, etc., follow roughly Gaussian distributions, with few members at the high and low ends and many in the middle. Computer Algebra Systems Function Maple Mathematica Probability Density Function statevalf[pdf,dist](x) PDF[dist, x] - frequency of occurrence at x Cumulative Distribution Function statevalf[cdf,dist](x) CDF[dist, x] - integral of probability density function up to x dist = normald[µ, σ] dist = NormalDistribution[µ, σ] µ = 0 (mean) µ = 0 (mean) σ = 1 (std. dev.) σ = 1 (std. dev.) Potential Applications 1. Statistical Averaging: 7 Error Function The error function is obtained by integrating the normalized Gaussian distribution. x 2 Z 2 erf x = p e−t dt (1.4) π 0 where the coefficient in front of the integral normalizes erf(1) = 1. A plot of erf x over the range −3 ≤ x ≤ 3 is shown as follows. 1 0.5 L x H 0 erf -0.5 -1 -3 -2 -1 0 1 2 3 x Figure 2.3: Plot of the Error Function The error function is defined for all values of x and is considered an odd function in x since erf x = −erf (−x). The error function can be conveniently expressed in terms of other functions and series as follows: 1 1 erf x = p γ ; x2 (1.5) π 2 2x 1 3 2x 2 3 = p M ; ; −x2 = p e−x M 1; ; x2 (1.6) π 2 2 π 2 1 2 X (−1)nx2n+1 = p (1.7) π n=0 n!(2n + 1) where γ(·) is the incomplete gamma function, M(·) is the confluent hypergeometric function of the first kind and the series solution is a Maclaurin series. 8 Computer Algebra Systems Function Maple Mathematica Error Function erf(x) Erf[x] Complementary Error Function erfc(x) Erfc[x] Inverse Error Function fslove(erf(x)=s) InverseErf[s] Inverse Complementary fslove(erfc(x)=s) InverseErfc[s] Error Function where s is a numerical value and we solve for x Potential Applications 1. Diffusion: Transient conduction in a semi-infinite solid is governed by the diffusion equation, given as @2T 1 @T = @x2 α @t where α is thermal diffusivity. The solution to the diffusion equation is a function of either the erf x or erfc x depending on the boundary condition used. For instance, for constant surface temperature, where T (0; t) = Ts T (x; t) − Ts x = erfc p Ti − Ts 2 αt 9 complementary Error Function The complementary error function is defined as erfc x = 1 − erf x 1 2 Z 2 = p e−t dt (1.8) π x 2 1.5 L x H 1 erf 0.5 -3 -2 -1 0 1 2 3 x Figure 2.4: Plot of the complementary Error Function and similar to the error function, the complementary error function can be written in terms of the incomplete gamma functions as follows: 1 1 erfc x = p Γ ; x2 (1.9) π 2 As shown in Figure 2.5, the superposition of the error function and the complementary error function when the argument is greater than zero produces a constant value of unity. Potential Applications 1. Diffusion: In a similar manner to the transient conduction problem described for the error function, the complementary error function is used in the solution of the diffusion equation when the boundary conditions are constant surface heat flux, where qs = q0 1=2 2 2q0(αt/π) −x q0x x T (x; t) − Ti = exp − erfc p k 4αt k 2 αt 10 1 Erf x + Erfc x 0.8 Erf x L x H 0.6 erf 0.4 0.2 Erfc x 0 0.5 1 1.5 2 2.5 3 x Figure 2.5: Superposition of the Error and complementary Error Functions @T and surface convection, where −k = h[T1 − T (0; t)] @x x=0 p 2 " !# T (x; t) − Ti x hx h αt x h αt = erfc p − exp + erfc p + 2 T1 − Ti 2 αt k k 2 αt k 11 Relations and Selected Values of Error Functions erf (−x) = −erf x erfc (−x) = 2 − erfc x erf 0 = 0 erfc 0 = 1 erf 1 = 1 erfc 1 = 0 erf (−∞) = −1 Z 1 p erfc x dx = 1= π 0 Z 1 p p erfc2 x dx = (2 − 2)= π 0 Ten decimal place values for selected values of the argument appear in Table 2.1.