Qudrture Module Contents Module 11.4: ng qud util Numericl Integrtion Utilities ng qud util provides utility procedures for computtion involving integrtion of functions, e.g., the computtion of the weights nd bscisse for Gussin integrtion rules. Contents Introduction... 11.4.3 Procedures ng qud gs wt bsc... 11.4.5 Clcultion of weights nd bscisse for Gussin qudrture rules, generl choice of rule Exmples Exmple 1: Abscisse nd weights by Guss Legendre formul... 11.4.11 Additionl Exmples... 11.4.13 References... 11.4.14 [NP3245/3/pdf] Module 11.4: ng qud util 11.4.1
Module Contents Qudrture 11.4.2 Module 11.4: ng qud util [NP3245/3/pdf]
Qudrture Module Introduction Introduction This module provides procedures which perform tsks in numericl integrtion. Currently, one procedure is vilble which computes the weights (norml or djusted) nd bscisse for six different types of Gussin integrtion rules. [NP3245/3/pdf] Module 11.4: ng qud util 11.4.3
Module Introduction Qudrture 11.4.4 Module 11.4: ng qud util [NP3245/3/pdf]
Qudrture ng qud gs wt bsc Procedure: ng qud gs wt bsc 1 Description ng qud gs wt bsc computes the weights (norml or djusted) nd bscisse ssocited with six different Guss rules. These weights nd bscisse my be used for the pproximtion of definite integrls (see Stroud nd Secrest [2], or pges 73 105 of Dvis nd Rbinowitz [1]). 2 Usge USE ng qud util CALL ng qud gs wt bsc(rule,, b, wt, x [, optionl rguments]) 3 A rguments Note. All rry rguments re ssumed-shpe rrys. The extent in ech dimension must be exctly tht required by the problem. Nottion such s x(n) is used in the rgument descriptions to specify tht the rry x must hve exctly n elements. This procedure derives the vlue of the following problem prmeter from the shpe of the supplied rrys. n 1 the number of Gussin weights nd bscisse 3.1 Mndtory Arguments rule integer, intent(in) Input: indictes the qudrture rule to be used s specified in Section 6.1: if rule = 0 for the Guss Legendre rule; if rule = 1 for the Guss Jcobi rule with norml weights; if rule = 1 for the Guss Jcobi rule with djusted weights; if rule = 2 for the Guss Exponentil rule with norml weights; if rule = 2 for the Guss Exponentil rule with djusted weights; if rule = 3 for the Guss Lguerre rule with norml weights; if rule = 3 for the Guss Lguerre rule with djusted weights; if rule = 4 for the Guss Hermite rule with norml weights; if rule = 4 for the Guss Hermite rule with djusted weights; if rule = 5 for the Guss Rtionl rule with norml weights; if rule = 5 for the Guss Rtionl rule with djusted weights. Constrints: 5 rule 5. rel(kind=wp), intent(in) b rel(kind=wp), intent(in) Input: the prmeters nd b which occur in the qudrture formule s specified in Section 6.1. Constrints: If rule =0,±1 or±2, then < b; if rule = ±3, then b 0; if rule = ±4, then b > 0; if rule = ±5, then + b 0. [NP3245/3/pdf] Module 11.4: ng qud util 11.4.5
ng qud gs wt bsc Qudrture wt(n) rel(kind=wp), intent(out) x(n) rel(kind=wp), intent(out) Output: the n weights nd bscisse of the Guss rule. Note: if rule = 2 or 4 nd the optionl rgument c 0.0, then n odd number of weights nd bscisse, n, my rise n error condition (see error%code = 204 in Section 4). 3.2 Optionl Arguments Note. Optionl rguments must be supplied by keyword, not by position. The order in which they re described below my differ from the order in which they occur in the rgument list. c rel(kind=wp), intent(in), optionl d rel(kind=wp), intent(in), optionl Input: the prmeters c nd d which occur in some of the qudrture formule (see Section 6.1). For some rules c nd d must not be too lrge (see Section 4). Note: If rule =0,thenc nd d should not be present; if rule = ±2, ±3 or±4, then d should not be present. Constrints: if rule = ±1, then c > 1 ndd > 1; if rule = ±2, ±3 or±4, then c > 1; if rule = ±5, then c > 1 ndd > c +1. error type(ngerror), intent(inout), optionl The NAG fl 90 error-hndling rgument. See the Essentil Introduction, or the module document ng error hndling (1.2). You re recommended to omit this rgument if you re unsure how to use it. If this rgument is supplied, it must be initilized by cll to ng set error before this procedure is clled. 4 Error Codes Ftl errors (error%level = 3): error%code Description 301 An input rgument hs n invlid vlue. 303 Arry rguments hve inconsistent shpes. 305 Invlid bsence of n optionl rgument. Filures (error%level = 2): error%code Description 201 Convergence not chieved. ng sym tridig eig ll hs filed to obtin convergence. 202 One or more of the weights re lrger thn HUGE(1.0 wp), the lrgest floting-point number on this mchine. The overflowing weights re returned s HUGE(1.0 wp). Possible solutions re to use smller vlue of n; or, if using djusted weights, to chnge to norml weights. To exmine the vlues of the weights fter this filure, you must supply the optionl rgument error nd initilise it using ng set error nd set hlt level to 3 (see the Essentil Introduction or the module ng error hndling for hndling error exits). 11.4.6 Module 11.4: ng qud util [NP3245/3/pdf]
Qudrture ng qud gs wt bsc 203 One or more of the weights re too smll to be distinguished from zero on this mchine. The underflowing weights re returned s zero, which my be usble pproximtion. Possible solutions re to use smller vlue of n; or, if using norml weights, to chnge to djusted weights. To exmine the vlues of the weights fter this filure, you must supply the optionl rgument error nd initilise it using ng set error nd set hlt level to 3 (see the Essentil Introduction or the module ng error hndling for hndling error exits). 204 Guss Exponentil or Guss Hermite djusted weights with n odd nd c 0.0. Theoreticlly, in these cses: for c > 0.0, the centrl djusted weight is infinite, nd the exct function f(x) is zero t the centrl bsciss; for c < 0.0, the centrl djusted weight is zero, nd the exct function f(x) is infinite t the centrl bsciss. In either cse, indeterminte. the contribution of the centrl bsciss to the summtion is In prctice, the centrl weight my not hve overflowed or underflowed, if there is sufficient rounding error in the vlue of the centrl bsciss. If the soft fil option is used, the weights nd bsciss returned my be usble; the user must be prticulrly creful not to round the centrl bsciss to its true vlue without simultneously rounding the centrl weight to zero or s pproprite, or the summtion will suffer. It would be preferble to use norml weights, if possible. It is importnt to remember tht, when switching from norml weights to djusted weights or vice vers, redefinition of f(x) isinvolved. Wrnings (error%level = 1): error%code Description 101 Optionl rgument present but not used If rule =0,cnd d should not be present; if rule = ±2 or±3 or±4, d should not be present. 5 Exmples of Usge Acomplete exmple of the use of this procedure ppers in Exmple 1 of this module document. 6 Further Comments 6.1 Mthemticl Bckground This procedure computes the weights w i nd bscisse x i for use in the summtion S = n w i f(x i ) i=1 which pproximtes definite integrl (see Stroud nd Secrest [2], or pges 73 105 of Dvis nd Rbinowitz [1]). The following types re provided: [NP3245/3/pdf] Module 11.4: ng qud util 11.4.7
ng qud gs wt bsc Qudrture 1. Guss Legendre: b Constrint: b>. 2. Guss Jcobi: norml weights: b djusted weights: b f(x) dx, exct for f(x) =P 2n 1 (x). (b x) c (x ) d f(x) dx, exct for f(x) =P 2n 1 (x), f(x) dx, exct for f(x) =(b x) c (x ) d P 2n 1 (x). Constrint: c> 1, d> 1, b>. 3. Guss Exponentil: norml weights: b x + b c 2 f(x) dx, exct for f(x) =P 2n 1 (x), djusted weights: b f(x) dx, exct for f(x) = x + b c 2 P 2n 1 (x). Constrint: c> 1, b>. 4. Guss Lguerre: norml weights: djusted weights: x c e bx f(x) dx (b >0), x c e bx f(x) dx (b <0), exct for f(x) =P 2n 1 (x), f(x) dx (b >0), Constrint: c> 1, b 0. 5. Guss Hermite: norml weights: + djusted weights: + Constrint: c> 1, b>0. f(x) dx (b <0), exct for f(x) = x c e bx P 2n 1 (x). x c e b(x )2 f(x) dx, exct for f(x) =P 2n 1 (x), f(x) dx, exct for f(x) = x c e b(x )2 P 2n 1 (x). 11.4.8 Module 11.4: ng qud util [NP3245/3/pdf]
Qudrture ng qud gs wt bsc 6. Guss Rtionl: norml weights: S x c f(x) dx ( + b>0), x + b d x c ( ) 1 x + b d f(x) dx ( + b<0), exct for f(x) =P 2n 1, x + b djusted weights: S f(x) dx ( + b>0), f(x) dx ( + b<0), exct for f(x) = ( ) x c 1 x + b d P 2n 1. x + b Constrint: c> 1, d>c+1, + b 0. In the bove formule, P 2n 1 (x) stnds for ny polynomil of degree 2n 1orlessinx. 6.2 Algorithmic Detil The method used is to clculte the bscisse, using ng sym tridig eig ll to find the eigenvlues of the pproprite tridigonl mtrix (see Golub nd Welsch [3]). The weights re then determined by the formul: 1 n 1 w i = Pj (x i ) 2 j=0 where Pj (x) isthejth orthogonl polynomil with respect to the weight function over the pproprite intervl. 6.3 Accurcy The ccurcy depends minly on n, with incresing loss of ccurcy for lrger vlues of n. Typiclly, one or two deciml digits my be lost from mchine ccurcy with n 20, nd three or four deciml digits my be lost for n 100. 6.4 Timing The mjor portion of the time is tken up by ng sym tridig eig ll during the clcultion of the bscisse, where the time is roughly proportionl to n 3. [NP3245/3/pdf] Module 11.4: ng qud util 11.4.9
ng qud gs wt bsc Qudrture 11.4.10 Module 11.4: ng qud util [NP3245/3/pdf]
Qudrture Exmple 1 Exmple 1: Abscisse nd weights by Guss Legendre formul Genertes bscisse nd weights using the Guss Legendre 7-point formul. 1 Progrm Text Note. The listing of the exmple progrm presented below is double precision. Single precision users re referred to Section 5.2 of the Essentil Introduction for further informtion. PROGRAM ng_qud_util_ex01! Exmple Progrm Text for ng_qud_util! NAG fl90, Relese 3. NAG Copyright 1997.!.. Use Sttements.. USE ng_exmples_io, ONLY : ng_std_out USE ng_qud_util, ONLY : ng_qud_gs_wt_bsc!.. Implicit None Sttement.. IMPLICIT NONE!.. Intrinsic Functions.. INTRINSIC KIND!.. Prmeters.. INTEGER, PARAMETER :: n = 7 INTEGER, PARAMETER :: wp= KIND(1.0D0)!.. Locl Sclrs.. INTEGER :: j, rule REAL (wp) ::, b!.. Locl Arrys.. REAL (wp) :: wt(n), x(n)!.. Executble Sttements.. WRITE (ng_std_out,*) Exmple Progrm Results for ng_qud_util_ex01 = -1.0_wp b = 1.0_wp rule = 0 CALL ng_qud_gs_wt_bsc(rule,,b,wt,x) WRITE (ng_std_out,*) WRITE (ng_std_out, (1X,A,I3,A) ) Legendre formul,, n, points WRITE (ng_std_out,*) WRITE (ng_std_out, (6X,A,8X,A) ) Abscisse, Weights WRITE (ng_std_out,*) WRITE (ng_std_out, (2F15.5) ) (x(j),wt(j),j=1,n) END PROGRAM ng_qud_util_ex01 2 Progrm Dt None. 3 Progrm Results Exmple Progrm Results for ng_qud_util_ex01 Legendre formul, Abscisse 7 points Weights -0.94911 0.12948-0.74153 0.27971-0.40585 0.38183 [NP3245/3/pdf] Module 11.4: ng qud util 11.4.11
Exmple 1 Qudrture 0.00000 0.41796 0.40585 0.38183 0.74153 0.27971 0.94911 0.12948 11.4.12 Module 11.4: ng qud util [NP3245/3/pdf]
Qudrture Additionl Exmples Additionl Exmples Not ll exmple progrms supplied with NAG fl 90 pper in full in this module document. The following dditionl exmples, ssocited with this module, re vilble. ng qud util ex02 Genertes bscisse with both weights nd djusted weights using the Guss Jcobi 7-point formul. ng qud util ex03 Genertes bscisse with both weights nd djusted weights using the Guss Exponentil 7-point formul. ng qud util ex04 Genertes bscisse with both weights nd djusted weights using the Guss Lguerre 7-point formul. ng qud util ex05 Genertes bscisse with both weights nd djusted weights using the Guss Hermite 7-point formul. ng qud util ex06 Genertes bscisse with both weights nd djusted weights using the Guss Rtionl 7-point formul. [NP3245/3/pdf] Module 11.4: ng qud util 11.4.13
References Qudrture References [1] Dvis P J nd Rbinowitz P (1975) Methods of Numericl Integrtion Acdemic Press [2] Stroud AH nd Secrest D (1966) Gussin Qudrture Formuls Prentice-Hll [3] Golub G H nd Welsch J H (1969) Clcultion of Guss qudrture rules Mth. Comput. 23 221 230 11.4.14 Module 11.4: ng qud util [NP3245/3/pdf]