Dewhurst 1996 Micro Processing and Micro Programming

download Dewhurst 1996 Micro Processing and Micro Programming

of 4

Transcript of Dewhurst 1996 Micro Processing and Micro Programming

  • 8/9/2019 Dewhurst 1996 Micro Processing and Micro Programming

    1/4

    ELSEVIER

    An improved algorithm for evaluation of the productof an exponential function with an error function complementR.J. Dewhurst, Q. Shan *

    DIA S, UM IST, P.O. Box 88, Manchest er. M 60 1 QD, UKReceived 17 January 1995; evised 11 April 1995; accepted 24 July 1995

    MicroprocessingandMicroprogrammingMicroprocessing and Microprogramming 41 (1996) 733-736

    AbstractSome mathematical CAD packages are inadequate in computing the composite functions involving the product of an

    exponential function and an error function complement. These functions arise in physical applications, such as problems indiffusion. Their importance warrants a composite treatment. If their component factors are computed individually,discontinuities in the evaluations arises, as shown in some CAD packages. An improved algorithm is presented whichovercomes this deficiency, and provides a fast evaluation. Such evaluation is successful even using floating point numberswith single precision. The potential for numerical ovefflow associated with large arguments has been overcome.Keywords: Round-off errors; Numerical calculations; Fast algorithms

    1. IntroductionRound-off errors have already been treated inmany publications, such as the one by Burden andFaires [l]. The topic is familiar to programmers who

    use computer languages instead of CAD packages.Since these packages are playing a more importantrole in science and engineering computations, it is

    worth noting that some divergency problems maynot be mathematical or scientific ones. Instead, theymay arise from some deficiencies in the computingprocess. Such a case is described below.The complementary error function with parameterI is defined as [2]

    erfc( t) = &l^exp( -x2) dx (1)

    * Corresponding author. Email: [email protected] is widely used in problems of heat conduction andsimilar situations concerned with the diffusion of

    0165~6074/%/$15.00 0 1996 Elsevier Science B.V. All rights reservedSSDI 0165-6074(95)00026-7

  • 8/9/2019 Dewhurst 1996 Micro Processing and Micro Programming

    2/4

    134 RJ. Dew hursi. Q. Shan/M icroprocessing and Mi croprogram mi ng 41(1996) 733-736

    matter or energy. In practical applications, it oftenoccurs as a product accompanied with an exponentialfunction of the square of its argument, in the formy = exp( 2) erfc( r) (2)For example, in some Laplace translation tables [3,4],the complementary error function always appearstogether with exp(t*). As a matter of fact, the com-posite function, represented by Eq. (21, is so impor-tant that it warrants separate treatment in some math-ematical books [2,4]. However, the computation ofthis function has been found to be inadequate usingsome CAD packages [5]. In the following discussion,it is shown that the problem is related to the preci-sion of floating point numbers used to evaluate thefunction. An improved algorithm is therefore pre-sented to correct this problem, at the same timeproviding a faster method for the calculation of thefunction. No increase is required in the precision offloating point numbers. For software packages hav-ing a symbolic processor, this paper demonstratesthat the overflow problem associated with functionsinvolving with error function complement can beovercome by adopting the new algorithm.

    2. ComputationThe approach adapted here is based on the algo-

    rithm by Spanier and Oldham [2]. Their algorithmfor Eq. (1) uses concatenated forms of expansion,truncated at j = 3 + lnt(9 1 I), taking the form [2]erfc( t) = 1 - f 2 (-9)6 j=O .i!( + 1/2)to evaluate y for - 1.5 G t =G1.5, where j is the loopvariable anderfc( t)

    =exp(-1)2 3 2+Int(32/t)----...rfi++T+fi+fi+tE1 4)

    for I t I > 1.5. To calculate Eq. (2), we have simplymodified Eqs. (3) and (41, such thatexp( t) er fc( t)

    =exp(t2) [ l-t e (-f2) 1;; j=O j!(j+ l/2) (5)

    to evaluate y for - 1.5 < t B 1.5, andexp(r) erfc(t)

    WI2 3 2 + Int(32/t)=--pp...rfi+ lfi+ tfi+ rJZ+ rfi (6)

    for I tl > 1.5.

    3. ResultsA calculated solution of Eq. (2) is plotted as asolid line in Fig. 1, using the algorithm represented

    by Eqs. (5) and (6). For comparison, results fromsome CAD packages are also presented in Fig. 1.The dashed line is a result from Mathcad and thedotted line a result from Matlab 151. Both packages

    -2, I

    Fig. 1. Three curves for the calculation of function y =exp(r*) erf&). The solid line is the result obtained from the newalgorithm; the dashed line is that derived from MathCad and thedotted line is that derived form Matlab. Only the solid line showsthe smooth nature of the function. The other curves show disconti-nuities at around 5 g I < 6.

  • 8/9/2019 Dewhurst 1996 Micro Processing and Micro Programming

    3/4

    R J. Dewhurst, Q. Shan /Microprocessing and Microprogramming 41 (1996) 733-736 135

    .m J\\ Result from a CAD pac kage (ASYSTANT)i60 - \ - - - - calculation usmg double preasion

    - \ calculationsingSIngIt?rewmny.40 - \

    L. I.20 - .-.. -.-.____ ;-435 - _ ---__#A I.cc - L_.....-_-_-----_-20 t:0 1 2 3 4 5 6 7 8

    tFig. 2. Results of computing y = exdt*) erfc(t) by Asystant inthe region 0 Q r ,< 8. The solid line is the result obtained usingfloating point with double precision, and the dashed line is theresult obtained using floating point numbers with single precision.The discontinuity deficiency is related to the precision of floatingpoint numbers. The higher the precision, the greater t may bebefore a discontinuity occurs.

    used double precision to represent floating pointnumbers in their computation, and both calculatedcurves show deficiencies with discontinuities at 5 Q tG 6. Following the last discontinuous jump at tclose to 5.9, the ordinate values in both softwarepackages go to zero, with the values remaining atzero for t > 6. This is in contrast with calculationsusing equation (6) where the curve remains continu-ous with ordinate values close to 0.1 for c = 6.

    Another software package, Asystant [5], has asimilar problem. In Asystant, floating point numberscan be defined as single precision or double preci-sion. Using these two kinds precision, calculatedresults using Asystant software package are plottedin Fig. 2. Use of double precision calculations(dashed line) lead to discontinuities between 5.5 and6, whilst that of single precision calculations (dottedline) lead to discontinuities between 3.5 and 4. Thefigure shows that the longer the data type the smallerthe discontinuities and the greater r before disconti-nuities appear.

    Having a reliable method for computing Eq. (2) isimportant. For example, it may be used as a basis tosolve related functions such asy = exp( t) . erfc( fi) (7)y = exp( t) . erfc( - 14) (8)y = 6. exp( t) . erfc(fi) (9)and so on. All these function arise in physical appli-cations, such as those encountered when solvingproblems in diffusion.

    Additionally, the new algorithm, expressed byEqs. (5) and (6), may also be used to solve somemathematical computational problems which do nothave the same form of Eqs. (2), (71, (8) or (9). Thefollowing equation is such an example:y = exp( ab + b2t) . erfc kat f I2 + bt 12 * (10)This example is taken from an inverse Laplace trans-form table (entry 5.96 in [4]). It is also part of theexpression shown in the same reference in entries5.95, 5.98-5.104. If parameter b in Eq. (10) has alarge value, the value for 1 has to be limited to acertain value when computer evaluation is required.Otherwise the term exp(b2t) overflows. Conse-quently if there are interesting features requiring Eq.(10) to be evaluated at large t, a difficulty related tooverflow can arise. In this case, Eq. (10) may beexpressed alternatively as

    -l /2 + bf/2 (1)Now Eq. (11) is bounded for all t > 0 and can besolved by an algorithm similar to that which solvedEq. (2).

  • 8/9/2019 Dewhurst 1996 Micro Processing and Micro Programming

    4/4

    736 RJ. Dewhurst, Q. Shan/Microprocessing and Microprogramming 41 (1996) 733-736

    4. ConclusionsAn improved algorithm has been proposed to

    solve a deficiency in some commercial mathematicalCAD software packages. The algorithm does notrequire an increase on the length of floating pointnumbers needed for its evaluation. It requires lesscomputating resources and is quicker in the evalua-tion of composed functions of the formexp(f*) erfc(t) than those adopted by these CADpackages. Our recommendation to mathematicalCAD software vendors is that, wherever possible,their syntax analyzer should convert a users originalexpression such as Eq. (IO) into a form of equationsuch as (1 l), allowing the appropriate algorithm tobe computed at high speed without overflow prob-lems. This should cause no difficulty to a packagewhich features symbolic operation.

    References[l] R.L. Burden and J.D. Fain%, Numerical Analysis, fourth ed.

    (PWS-Kent, London, 1989) 10-29.[2] J. Spanier and K. Oldham. An Atlas of Functions (Hemisphere

    Publishing, Washington, 1987) Ch. 40, p. 385.[3] F. Oberhettinger and L. Badii, Tables ofLuplaceTransforms(Springer-Verlag, Berlin, 1973) p. 43, pp. 229-23 1.[4] R.V. Churchill, Operational Mathematics, third ed.(McGraw-Hill, Tokyo, 1972) 48 1.

    151 Software packages which exhibit a deficiency include Asys-taut of Asyst Software Technology, Mathcad 4.0 of MathSoftand Matlab 4.0a of MathWorks.

    Richard J Dewhurst has some twenty-five years experience in the field ofoptical engineering and its applications.After holding positions at the Universi-ties of Hull and Stratbclyde, he now hasa Chair in Instrumentation in the Depart-ment of Analytical science at UMIST,Manchester. His research interests spanthe areas of non-destructive testing, ma-terials characterisation, quality controland medical engineering. In severalcases laser-generated ultrasound is used,using an interdisciplinary approach todevelop new forms of instrumentation. These have include newinterferometer instruments for the detection of ultrasound, sufft-ciently sensitive record signals from industrial surfaces, and newphotoacoustic devices for applications in mediciue.

    tions. Due to his workUltrasonic internationalAward by the America 5

    Qing Shan received BSc and MSc fromQingdao University of Chemical Tech-nology and East China University ofScience and Technology in 1982 and1984, respectively. He received a PhDin laser ultrasonics from UMIST in 1992.Shari is presently a postdoctoral researchassociate in the Department of Instm-mentation. UMIST. His interests includenondestmctive testing of engineeringmaterials by remote laser-ultrasonicstechniques and modelling of photoa-caustics in medical engineering applica-:, he received a Stephens Prize during91 and the 1994s Outstanding Papersociety for Nondestructive Testing.