and development command ws--etc fig 12/1 ...ad-ai20 107 army electronics research and development...
TRANSCRIPT
AD-AI20 107 ARMY ELECTRONICS RESEARCH AND DEVELOPMENT COMMAND WS--ETC FIG 12/1
ASI MPLIFI C ATI ON OF LENTZ S ALGOR!THM.( G82wjLNZ
UNCLASSIFIED ERADCOM/ASL-TM 0118 NEEEEEomhohiEE
TR-01 18[A Reports Control SymbolQSD 1366
lye A SIMPLIFICATION OF LENTZ'S ALGORITH14
AUJGUST 1982
By
Wd. J. Lentz
Approved for public release; distribution unlimited.
9 US Army Electronics Research and Development Command
Atmospheric Sciences LaborstoryWhite Sands Missile Range, NM 880-12
82 10 12 018
NOT IC ES
Disclaimers
The findings in this report are not to be construed as anofficial Department of the Army position, unless so desig-nated by other authorized documents.
The citation of trade names and names of manufacturers inthis report is not to be construed as official Governmentindorsement or approval of commercial products or swvicyerefereoced herein.
Disposition
Destroy this report when it is no longer needed. Do notreturn it to the originator.
ERRATA
ASL-TR-0118
A SIMPLIFICATION OF LENTZ'S ALGORITHM
Please change subject document as follows.
Page 7, sixth line from bottom of page, change and the
denominator [-1,1]" to and the denominator [1,-i]"
NI
UI
i
SECURITY CLASSIFICAT ION OF THIS PAGE I~en Date, Entered)
_______________________________________READ INSTRUCTIONSL~PNP~(A REPORT DOCUMENTATION PAGE BEFORE COMPLETING FORM
1. REPORT NUMBER 127 GOVT ACCESSION NO. 3. RECIPIENT'S CATALOG NUMBER
ASL-TR-01184 t4)~~/~r4. TITLE (anid Subtitle) S. TYPE OF REPORT & PERIOD COVERED
A SIMPLIFICATION OF LENTZ'S ALGORITHM Final Report6 PERFORMING ORG. REPORT NUMBER
7. AUTHOR~'.) S. CONTRACT OR GRANT NUMBER(*)
W. J. Lentz
9. PERFORMING ORGANIZATION NAME AND ADDRESS 10. PROGRAM ELEMENT. PROJECT, TASKAREA & WORK U NIT NUMBERS
US Army Atmospheric Sciences LaboratoryWhite Sands Missile Range, NM, 88002 DA Task lL162111AH71-DO
it. CONTROLLING O FFICE NAME AND ADDRESS 12, REPORT DATE
Us Army El1ectronics Research and August 1982Development Commnand13NUBROPAE
Adeiphi, MD 20783 114. &ONITORIN4G AGENCY NAME & ADDRESSII dillfernt from Controflinif Office) IS. SECURITY CLASS. (of this report)
IS. DISTRIBUTION STATEMENT (of this Report) SHDL
Approved for public release; distribution unlimited.
17. DISTRIBUTION STATEMENT (of the. abstract entered In Block 20. It differeni from Report) j
It. SUPPLEMENTARY NOTES
IS. KEY WORDS (Continue on reverse side If necesry and Identify by block num~ber)
Continued Fractions AlgorithmComplex Bessel Functions Spherical Bessel FunctionsM4ie Scattering
AUSTrAcr F(cautame sr- New .*i nggeway mad idevify by block number)
The Lentz algorithm is a method of computing the continued fractionrepresentation of functions. It was originally developed to calculatespherical Bessel functions in Mie scattering calculations. A simplificationof the algorithm improvement is presented for the case in which a given termis exactly zero. A FORTRAN IV program is presented which calculates threetest cases correctly when the numerator or denominator terms are exactly zero.
DD 1473 Eve-noes or i Nov 6s is oUSOLETE __________________
SECUITY CLASSIFICATION OF THIS PAGE (When Date Entered)
CONTENTS
INTRODUCTION.................................. ..................... 5
BACKGROUND......................................................... 5
Original Algorithm Improvement ....................................... 6
Numerical Examples ................................................. 7
DISCUSSION OF THE SIMPLIFICATION ..................................... 8
Simplified Error Removal............................................ 8
SUMMARY............................................................ 9
APPENDIX A FORTRAN IV PROGRAM SIMPLE.FR ............................. 10
COpW-Np~e
2P '
,I.
INTRODUCTION
The ratios of spherical Bessel functions of complex argument are needed forMie calculations of scattering and absorption. Lentz has developed a newcontinued fraction technique' for evaluating these ratios, with an improvementto eliminate errors when certain terms approach or become zero. The authorsof a recent note,' however, had difficulty in applying the algorithmimprovement when either the numerator or denominator was exactly zero. Thiscase is special, and a simplification is possible. The purpose of this paperis to present an algorithm for this special case, together with someclarifying remarks concerning its development.
BACKGROUND
The Lentz algorithm is simply a way of calculating continued fractions; thealgorithm begins at the beginning of the continued fraction rather than atsome indeterminate final coefficient. An improvement formula allows one tobypass any step in which a given numerator or denominator might be zero (tothe accuracy of the computer). In addition, roundoff errors may be reduced byusing the algorithm improvement. When applied to the continued fractionrepresentation of ratios of Bessel functions, the method is easy to use andfree of most of the weaknesses of the other algorithms used to generate ratiosof Bessel functions. 2
Let us review the method of computing a continued fraction by defining thesimple continued fraction. The simple continued fraction is defined forarbitrary an not equal to zero as
F = a1 + 1.0a2 + 1.0
a3 + 1.0a4 + ... (1)
which may be written as
I ~F a l+Li_
F a + ... , (2)
and the n'th partial convergent of the continued fracticn is
'Lentz, W. J., "Generating Bessel Functions in Mie Scattering CalculationsUsing Continued Fractions," Applied Optics, 15:668, 1976.
ljaaskelainen, T., and J. Ruuskanen, "Note on Lentz's Algorithm," AppliedOptics, 20:19, 1981.
. .. p~jj4 Pk5 5ha .lmo1 11PA
n a 2 + a3 + a4 + + an (3)
The Lentz algorithm is simply a way of computing the Fn without sta-tir.y at
some indeterminate last an. A further simplification of notation is needed:
Fn = [a,, a2 ., an (4)
Then the Lentz algorithm becomes
[aI [a2, a1) [a3, a2, 1] . .. [ar, an-I' . a1]
n - a2J La3, a2] ... Lan, an_ 1 ' .... a2 " (5)
Although the formula looks complicated, the successive numerators anddenominators are generated by taking the reciprocal of the previous numeratoror denominator and adding it to the next am.
When a given numerator is equal to its corresponding denominator (to thenumber of digits accuracy that is desired), the continued fraction is saie. tohave converged.
Original Algorithm Improvement
The original algorithm paper included an improvement technique to avoidinaccuracy when any term in the numerator or denominator approached or becamezero. The problem step is bypassed without loss of accuracy even if the termis exactly zero. Consider the following case in which I/a is equal to but ofopposite sign to am . When am is added to I/a, every digit that is the same in
the two terms will cancel and cause a loss of accuracy in the final number ifno steps are taken to bypass the problem. For example,
Let [a,-I, ..., al] =
If [a., ... , al] o - am + 1/a - 0
and [am+,1 ... , a = Y = am+ I + 1/B.
so [a2, ...1"2 a1 ] Z S am+2, + 1/y
Then C am+ 1 8 a, 0 + 1 (6)
-oj
where € is not necessarily 1.0.
The product of the two terms 8y E can be correctly calculated by equation(6). This avoids the problem of multiplying zero times infinity in equation(5).
& is the product of the next two terms. z, the next numerator or denominator,is then
am+2 y + 1 am+2 (am+i 8 + 1) + 8Y ~ am+1 8 + 1
am+2 + a + B/ (7
= m+2
The algorithm improvement may be applied to the denominator by replacing at by
a2 in the above equations. The algorithm improvement may be applied
independently to either the numerator or denominator or to both.
Numerical Examples
Consider the following three cases, which illustrate the implementation of thenormal Lentz algorithm and the Lentz algorithm with improvement.
Case A- Fna = -7 [1,2,2,2,2,...]
= 1* 3* 2.333*2.428571429* 2.411764706* 2.414634146
2 * 2.5 * 2.4 * 2.4166666666 * Z.41379313
Case B: Fnb = [1,1,-1,1,2] 0.5
Case C: Fnc [I,-1,1,-1,2] = 0.5
In case B the denominator [-1,1] is exactly zero, regardless of the computerword length. In case C both the numerator [-1,1] and the denominator [-1,1]are zero, causing both the numerator product and the denominator product to bezero. For case B one has:
_m [I1:] [1,1] [-1,1,1) [1,-I,1,1] [2,I,-1,1,1]nb UJLi L-I,i Ll,-l,1J LZ,1,-1,lI
Applying the algorithm improvement one has
FI ( 1 I( , 1 ] [ - ,I-1 , 1,, ,1 [2 , 1 , - 1 g ,1 ,1nb . 1 (1*0+1) {Z+Q/1}
7
where (1*0+1) corresponds to equation (6) and f2+0/1} corresponds to equation(7). The continued fraction is then calculated with ease:
F 1 * 2 * -0.5 * -1 * 1 = 0.5nb 1*1*I
In like manner, the improvement may be applied to more complicated cases, suchas case C, where corrections in both the numerator and denominator arerequi red:
Fnc L 'lIJ L-l,1,-I] J -,,1
In this case we have
F 1* (1*0+1) (-1+0/1) (2+1/-1) = 0.5
nc (-1) (-1*0+1) (2+0/1)
Notice that the term cannot be zero unless am+3 = 0, which is not allowed by
definition. If any am were zero in the derivation of a representation of a
function, the fraction could easily be transformed to the form of equation (2)by formula (5) of section 3.10.1 of Abramowitz.'
Up to this point we have not considered the Bessel functions for which theLentz algorithm was derived. Like Florida orange juice for breakfast, thealgorithm is not just for Bessel functions anymore. Rather, it is a generalway of computing the continued fraction representation of any function. Agood source of continued fraction representations of functions is found inAbramowitz together with the general properties of the functions.
DISCUSSION OF THE SIMPLIFICATION
Simplified Error Removal
In some cases it may not be desirable to include an error correction when oapproaches zero but is not identically zero. When either the numerator ordenominator is zero to the accuracy of the computer, a significantsimplification in programming is possible. This simplification reduces the
'Abramowitz, M. and I. A. Stegun, ed., Handbook of Mathematical Functions, USDepartment of Comm.erce, National Bureau of Standards, Washington, DC, 20402.
8
complexity of the algorithm and will often speed up its execution with littleloss of accuracy.
Consider equations (6) and (7) when B is exactly zero:
[am , ....a 1I] = B = 0
[am+i,...,aI] = y am+, + 1.0/8
[am+2 .... ,aI] Z = am+2 + B/ = am+ 2 (8)
And the product of the two terms By isZ = By = am+Is + 1 = 1
To include the simplified algorithm improvement, simply do not take thereciprocal of the previous numerator and denominator before adding the nextam+2. The running product is multiplied by one, so that it does not change if
the error bypass is implemented. This simplification was first published inthe Hewlett Packard 67 User's Library under Spherical Bessel functions., TheUser's Library program is no longer available, but the algorithm in appendix Adetails the methods used in that program.
SUMMARY
The original algorithm improvement in the computation of continued fractionsmay be applied to both the numerator and denominator of equation (5). Asimplified version of the improvement may be implemented in the case of anumerator or denominator being exactly zero. A FORTRAN IV programimplementing these ideas is listed for ease in use.
"Lentz, W. J., Hewlett Packard 67/97 User's Library, No 00642.
9
APPENDIX AFORTRAN IV PROGRAM SIMPLE.FR
Algorithm Example
The implementation of the simplified form of the algorithm improvement givenin equations (6) and (7) can be elusive. The best method to avoid pitfalls isto check the algorithm against well-defined cases such as Case B and Case C.The FORTRAN IV program Simple.FR, listed in appendix A, correctly calculatescases A, B, and C. The program was implemented on a Data General Nova 3minicomputer using FORTRAN V revision 6.11. The nonstandard accept and typestatements allow input and output in arbitrary format and may be replaced byread and write statements in standard FORTRAN IV. The variables have thefollowing functions:
AN the input terms of the continued fraction from equation (4)
NUM = the current partial numerator in equation (5)DEN = the current partial denominator in equation (5)
PDT the n'th convergent of the continued fraction formed the n
numerators and n-1 denominators in equation (5)
NFLAG = switch to avoid taking the reciprocal of zero in thk rator
DFLAG = switch to avoid taking the reciprocal of zero in the denominator
ICOUNT = counter to keep track of the current AN
10
S I IPLE.FR
1: PROGR~ri SIM"PLE IS DEI.TCHED TO PAVE SEPPATE LODCPS '70C NUM OND DE2: A P SiMPLIFIED Thl !- -4L- FOP-- LWi~JRkD TDErOM'lt4PTOP EO_ 4 rr P
3: C PROCPAN POISSES THE TE.T F THE HJLLJ D EPIES4: [.-12=U.53 PT '6E P T ?-Ot0,EPLENE
1,LL.L1,2JO0.5 AT T11< LPST1 fOFVJ-GEY CEr- C THE Tp 12S rEST'S THE [U O ITCP L&F (PhD THE SECOND TUE NULMFnPTJC:
EYPPS.
5: PEOL POT. NU 1.DEN, P]A
11: 1 TiPE ' ICLUHT"U, iflPUT ti'n~12: PCCEPT AH13: PDT=A4
15: DEH=0.O,
13: DFLPCG.1?-' !t*~*v' [n!)lt LOOP POINT AFTER III LiZTO*.*****w***v**wt20 10[ -if FUU. FD. DEN. rHtD.NFLPC. NE.1I.PND.OFLPC..NE. 1)TYPE "FRACTION HAS CONVERGED"'1 I COLIHI> ICOUIT-1
Y' 1 Pt 'PTT ", PDT, [COUNITT)FE "INPUT RNI"
-, ' ACCEPT il1IPkHN.E0.U) GOTO I
1: c STOP IF PN IS ZERO WJHICH Is HOT ALLOWED IN THE ALGORITHM: C****lTEST FOP fPEVIOUS NUMERATOR OR DENOMINATOR ZERO). IF SO SKIP STEP********'
-3 : [Ft [[EURO.! E. I) NUr'l=N'Ul-PN29: IF (DFLPiC. I4IE. 1 ) DEN -DEN-rAN30: HEFLAG =HFLPnG+ 1Z I: DFLPG =DFLR:C 1-l,2: P**C**t!3'% 1LO4NCI ORMAL NUMERATOR LOOP UNLESS ~ ?l*****t~*
5)3: IF(t!il.E7.fl) 5-OTO 113,1: PDT=PDTtNfUlI
35: Ull" 1 .0/"HUHob: 14FLOG=J37: C~*x~cctto1f~1-LO GIS DENOM I NATOR LO':***************38: 11 IF(DENI.EOKO) GOTO 1039: PDT=PDT/I)EIlQ J: DEN>'-- I.0O/DEN41: DFLnG=O42: COTO 1043: END
IDENTIFIER REFERENCES
AN 9 12 13 14 24 25 20 29DEN 9 15 28 29 Z P 35 4DFLAG 18 20 29 31 41ICOUNT 26 21 .2NFLAG 17 20 3U 36NU1m 9 14 20 28 3 24 35P T 9 13 22 34 29
1 11 25:0 20 :3 42
1233 38SIMPLE7COUNT=O, INPUT AN1.PDT= 3. 8fl08E I
'4PUT AN1.
PDT= 0.200000E 1 2flNPUT AM
PDT= -0.108000E1 3
INPUT AN1.PDT= 0.100000E 1 4INPUT AN2.PDT- 0.500008E 0 5INPUT AN0ICOUNT=9. INPUT ANI.PDT= 0.100000E 1 IINPUT AN-1.PDT= -0.1000E 1 2INPUT AN1.PDT- -0.10080E IINPUT AN-1.PDT 0.1080080E 1 4INPUT AN2.PDT- 0.500000E 0 5INPUT AN0ICOUNTa8, INPUT AN
j 12
DISTRIBUTION LIST
Commander Dr. Frank D. EatonUS Army Aviation Center Geophysical InstituteATTN: ATZQ-D-MA University of AlaskaFort Rucker, AL 36362 Fairbanks, AK 99701
JOHN M. HOBBIE Naval Weapons Centerc/o Kentron International Code 39182003 Byrd Spring Road ATTN: Dr. A. ShlantaHuntsville, AL 35807 China Lake, CA 93555
Chief, Atmospheric Sciences Div Commanding OfficerCode ES-81 Naval Envir Prediction Rsch FacilityNASA ATTN; LibraryMarshall Space Flight Center, AL 35812 Monterey, CA 93940
Commander Sylvania Elec Sys Western DivUS Army Missile Command ATTN: Technical Reports LibATTN: DRDMI-RRA/Dr.O. M. Essenwanger PO Box 205Redstone Arsenal, AL 35809 Mountain View, CA 94040
Commander Geophysics OfficerUS Army Missile Command PMTC Code 3250ATTN: DRSMI-OG (B. W. Fowler) Pacific Missile Test CenterRedstone Arsenal, AL 35809 Point Mugu, CA 93042
Commander CommanderUS Army Missile R&D Command Naval Ocean Systems CenterATTN: DRDMI-TEM (R. Haraway) (Code 4473)Redstone Arsenal, AL 35809 ATTN: Technical Library
San Diego, CA 92152Redstone Scientific Information CenterATTN: DRSMI-RPRD (Documents) Meteorologist in ChargeUS Army Missile Command Kwajalein Missile RangeRedstone Arsenal, AL 35809 PO Box 67
APO San Francisco, CA 96555CommanderHQ, Fort Huachuca DirectorATTN: Tech Ref Div NOAA/ERL/APCL R31Fort Huachuca, AZ 85613 RB3-Room 567
Boulder, CO 80302CommanderUS Army Intelligence Dr.B. A. Silverman D-1200
Center & School Office of Atmos Resources ManagementATTN: ATSI-CD-MD Water and Power Resources ServiceFort Huachuca, AZ 85613 PO Box 25007Denver Federal Center, Bldg. 67
Denver, CO 80225Comma nderUS Army Yuma Proving Ground Hugh W. Albers (Executive Secretary)ATTN: Technical Library CAO Subcommittee on Atmos RschBldg 2105 National Science Foundation Room 510Yuma, AZ 85364 Washington, DC 2055
13
Dr. Eugene W. Bierly US Army Materiel SystemsDirector, Division of Atmos Sciences Analysis ActivityNational Scinece Foundation ATTN: DRXSY-MP1800 G Street, N.W. APG, MD 21005Washington, DC 20550
CommanderCommanding Officer ERADCOMNaval Research Laboratory ATTN: DRDEL-PA/ILS/-EDCode 2627 2800 Powder Mill RoadWashington, DC 20375 Adelphi, MD 20783
Defense Communications Agency CommanderTechnical Library Center ERADCOMCode 222 ATTN: DRDEL-ST-T (Dr. B. Zarwyn)Washinqton, DC 20305 2800 Powder Mill Road
Adelphi, MD 20783Director 02Naval Research LaboratoryCode 5530 CommanderWashington, DC 20375 Harry Diamond Laboratories
ATTN: DELHD-CODr. J. M. MacCallum 2800 Powder Mill RoadNaval Research Laboratory Adelphi, MD 20783Code 1409Washington, DC 20375 Chief
Intel Mat Dev & Spt OfcHQDA (DAEN-RDM/Dr. de Percin) ATTN: DELEW-WL-IWashington, DC 20314 Bldg 4554
Fort George G. Mead, MD 20755The Library of CongressATTN: Exchange & Gift Div Acquisitions Section, IRDB-D823Washington, DC 20540 Library & Info Svc Div, NOAA2 6009 Executive Blvd.
Rockville, MD 20752Mil Asst for Atmos Sci Ofc of
the Undersecretary of Defense Naval Surface Weapons Centerfor Rsch & Engr/E&LS - RM 3D129 White Oak Library
The Pentagon Silver Spring, MD 20910Washington, DC 20301
Air Force Geophysics LaboratoryAFATL/DLODL ATTN: LCC (A. S. Carten, Jr.)Technical Library Hanscom AFB, MA 01731Eglin AFB, FL 32542
Air Force Geophysics LaboratoryNaval Training Equipment Center ATTN: LYDATTN: Technical Information Center Hanscom AFB, MA 01731Orlando, FL 32813
Meteorology DivisionTechnical Library AFGL/LYChemfcal Systems Laboratory Hanscom AFB, MA 01731Aberdeen Proving Ground, MD 21010
14
The Environmental Research CommanderInstitute of MI US Army Satellite Commn Agency
ATTN: IRIA Library ATTN: DRCPM-SC-3PO Box 8618 Fort Monmouth, NJ 07703Ann Arbor, MI 48107
Commander/Di rectorMr. William A. Main US Army Combat Survl & TargetUSDA Forest Service Acquisition Laboratory1407 S. Harrison Road ATTN: DELCS-DEast Lansing, MI 48823 Fort Monmouth, NJ 07703
Dr. A. D. Belmont DirectorResearch Division Night Vision & Electro-Optics LaboratoryPO Box 1249 ATTN: DELNV-L (Dr. R. Buser)Control Data Corp Fort Belvoir, VA 22060Minneapolis, MN 55440
Project ManagerCommander F IREFI NDER/REMBASSNaval Oceanography Command ATTN: DRCPM-FFR-TMBay St. Louis, MS 39529 Fort Monmouth, NJ 07703
Commanding Officer 6585 TG/WEUS Army Armament R&D Command Holloman AFB, NW 88330ATTN; DRDAR-TSS Bldg 59Dover, NJ 07801 AFWL/Technical Library (SUL)
Kirtland AFB, NM 87117CommanderERADCOM Scientific Advisor AFWL/WEATTN: DRDEL-SA Kirtland, AFB, NM 87117Fort Monmouth, NJ 07703
TRASANACommander ATTN: ATAA-SL (D. Anguiano)ERADCOM Tech Support Activity WSMR, W 88002ATTN: DELSD-LFort Monmouth, NJ 07703 Commander
US Army White Sands Missile RangeCommander ATTN: STEWS-PT-ALHQ, US Army Avionics R&D Actv White Sands Missile Range, NM 88002ATTN: DAVAA-OFort Monmouth, NJ 07703 Rome Air Development Center
ATTN: Documents LibraryCommander TSLD (Bette Smith)USA Elect Warfare Lab Griffiss AFB, NY 13441ATTN: DELEW-DA (File Cy)Fort Monmouth, NJ 07703 Environmental Protection Agency
Meteorology Laboratory, MD 80Commander Rsch Triangle Park, NC 27711US Army Electronics R&D CommandATTN: DELCS-SFort Monmouth, NJ 07703 US Army Research Office
ATTN: DRXRO-PPPO Box 12211Rsch Triangle Park, NC 27709
15
Commandant CommanderUS Army Field Artillery School US Army Night VisionATTN: ATSF-CD-MS (Mr. Farmer) & Electro-Optics LabFort Sill, OK 73503 ATTN: DELNV-D
Fort Belvoir, VA 22060CommandantUS Army Field Artillery School CommanderATTN: ATSF-CF-R USATRADOCFort Sill, OK 73503 ATTN: ATCO-FA
Fort Monroe, VA 23651CommandantUS Army Field Artillery School CommanderATTN: Morris Swett Lihrary USATRADOCFort Sill, OK 73503 ATTN: ATCD-IR
Fort Monroe, VA 23651CommanderUS Army Dugway Proving Ground Dept of the Air ForceATTN: STEDP-MT-DA-M 5WW/DN
(Mr. Paul Carlson) Langley AFB, VA 23665Ouqway, UT 84022
US Army Nuclear & Cml AgencyCommander A TN: MONA-WEUS Army Dugway Proving Ground Springfield, VA 22150ATTN: MT-DA-LDugway, UT 84022 Director
US Army Signals Warfare LabUS Army Dugway Proving Ground ATTN: DELSW-OS (or. Burkhardt)ATTN: STEDP-MT-DA-T Vint Hill Farms Station
(Dr. W. A. Peterson) Warrenton, VA 22186Dugway, UT 84022
CommanderInge Dirmhirn, Professor US Army Cold Regions Test CenUtah State University, UMC 48 ATTN: STECR-OP-PMLogan, UT 84322 APO Seattle, WA 98733
Defense Technical Information CenterATTN: DTIC-DDA-2Cameron Station, Bldg. 5Alexandria, VA 2231412
Commanding OfficerUS Army Foreign Sci & Tech CenATTN: DRXST-IS1220 7th Street, NECharlottesville, VA 22901
Naval Surface Weapons CenterCode G65Dahlgren, VA 22448
16' Ij
DATE
'ILMEI