Hands-On Math

Last Revision March, 2011

Last Revision March, 2011

A slightly different relationship to erf(x) is more frequently seen in

The error function, erf(), is used in physics, engineering etc., to determine the probability that events will occur between intervals of x. To determine values for erf(x) we must evaluate the integral on the right of the expression.

(Excel2000 provides the function ERF(z) but our aim is to demonstrate its calculation and provide a closed form approximation for erf(). The steps of doing so provide further insight into the use of the spreadsheet for one's own purposes.)

The rule employs weighted values of the integrand at n points within the interval. Points and weights for the interval from 1 to 2 for n = 4 are shown next.

Note that the abscissa labels are not proportionately spaced. Our calculation of erf(x) employs this 4 point Gaussian Quadrature Rule.

A plot of the integrand is shown next. It is a plot from columns B, for the abscissa, and G, for the ordinate, of the spreadsheet that was used to calculate it.

Representative cells from that spreadsheet now follow:

The expressions contained in the outlined cells can be seen by clicking their cell addresses following:

. | . |

E1 | C2 | E2 | G2 | I2 | C3 |

D3 | E3 | F3 | A6 | B6 | C6 |

D6 | E6 | F6 | G6 | H6 | I6 |

Returning to the spreadsheet: Column A is for future use. Its values run from zero to π/2 in steps of π/64000. Briefly, this column will later serve as abscissa values for a sine series approximation to erf(x).

Column B values run from 0 to 3.2 in steps of 0.0001, (C1), and forms the intervals of x for which the integrand is evaluated. The evaluations, (G6:G32005), employ the value for e, (G1), and four points within each interval, as seen for (C6:f6), using the weights shown at E1 and E2.

The incremental area, (H6), is formed as the product of the Gaussian Estimate of the integrand times the width of the interval, (C1), times the multiplier 2/√π, (I2).

The incremental areas are accumulated, summed, in column I to form the approximate erf(x) which

is plotted from the table as is seen next.

The average value of the relative differences is shown outlined at the top of the third column.

Although less than half of the full table is shown, it is surmised from the discontinuities, that ERF(x) is calculated in a sequence of ranges. For examples, the first range finishes at row 5513; the second range finishes at row 6996; and so on. A chart of the relative differences, which appear quite strange, follows:

One wonders which of erf(x) or ERF(x) is the more accurate. Few values for Erf() to be found on the web offer more than 7 decimal digits. IBM, at this location, provides a 10 decimal digit value, 0.8427007794 for x = 1.

In comparison: ERF(1) = 0.842700735175, differs from the IBM value by +0.000005248%. erf(1) = 0.842700792950, differs from the IBM value by -0.000001608%, less than 1/3 of the relative difference provided by ERF(x).

As a second check:

The corresponding value for erf() is shown at I4775 and its series approximation at J4775. L4775 contains the Excel2000 value, ERF(B4775). L4774 shows the relative error in percent of the table calculation with respect to 1/2. L4776 shows the relative error of ERF(B4775).

Both of the foregoing tests against other known values serve to provide more confidence in our spreadsheet table values than in the Excel2000 ERF() values.

The complement of erf(x) is expressed as erfc(x) where erfc(x) = 1 - erf(x) and is known as the error function complement. Excel2000 does not provide erfc(x).

The inverse of erf(x), the argument x of erf(x) for which erf(x) attains a specific value, is expressed as arcerf(x). Excel2000 does not provide an ARCERF(x). It can be obtained, approximately, by using their Goal Seek tool from the Tools menu as is illustrated next.

As seen in the foregoing, cell AL2 contains the value 1. As can be seen on the edit line, cell AM2 contains the expression =ERF(AL2) and shows the appropriate value in the cell. On selecting Goal Seek from the Tools menu, the small menu appears to allow entry of its parameters. Here we wish to change AL2 such that AM2 will attain the value 1/3. Clicking OK brings up:

Although AM2 is not exactly 1/3, it is close. Writing one’s own macro can provide a better approximation.

Goal Seek is quite a convenient tool and worth knowing.

erf(u) = aSIN(u)+bSIN(2u)+cSIN(3u)+........+iSIN(12u)+mSIN(13u)+nSIN(14u)

The sine series employs the variable u found in column A of the spreadsheet. Given a value for x, u can be found as: u = π * x / 6.4.

A plot of the error between the approximation and the table follows:

Note the almost uniform error extrema over the entire range of x. This effect was produced by raising each relative error between erf() and its approximation to the 12th power and using the average value of those errors as the objective function for the approximation. What this does is greatly increase the influence of large errors on the objective function, automatically providing them with more weight and thus providing a larger target for minimization.

In many situations the near uniform error extrema of relative error is a highly desirable feature of an approximation.

As an exercise, the viewer might try to improve on the approximation by approximating with functions other than the sine series. A polynomial series or the ratio of two polynomial series could be tried.

When

The next topic will employ the erf() function in a design problem.

Top | Next Topic | Topics |