QUADRATURE METHODS Kenneth L. Judd Hoover Institution July 19, 2011 1
Integrtion Most integrls cnnot be evluted nlyticlly Integrls frequently rise in economics Expected utility Discounted utility nd profits over long horizon Byesin posterior Likelihood functions Solution methods for dynmic economic models 2
Newton-Cotes Formuls Ide: Approximte function with low order polynomils nd then integrte pproximtion Step function pproximtion: Compute constnt function equlling f(x) t midpoint of [, b] Integrl pproximtion is UQV b box Liner function pproximtion: Compute liner function interpolting f(x) t nd b Integrl pproximtion is trpezoid P Rb 3
Prbolic function pproximtion: Compute prbol interpolting f(x) t, b, nd( + b)/2 Integrl pproximtion is re of P QRb 4
Midpoint Rule: piecewise step function pproximtion Simple rule: for some ξ [, b] f(x) dx =(b ) f ( ) + b + 2 (b )3 f (ξ) 24 Composite midpoint rule: f(x) dx =(b ) f ( ) + b + 2 nodes: x j = +(j 1 2 )h, j =1, 2,..., n, h =(b )/n for some ξ [, b] f(x) dx = h n f ( +(j 12 ) )h j=1 (b )3 f (ξ) 24 + h2 (b ) f (ξ) 24 5
Trpezoid Rule: piecewise liner pproximtion Simple rule: for some ξ [, b] Composite trpezoid rule: f(x) dx = b 2 [f()+f(b)] nodes: x j = +(j 1 2 )h, j =1, 2,..., n, h =(b )/n for some ξ [, b] (b )3 12 f (ξ) f(x) dx= h 2 [f 0 +2f 1 + +2f n 1 + f n ] h2 (b ) 12 f (ξ) 6
Simpson s Rule: piecewise qudrtic pproximtion for some ξ [, b] ( b f(x) dx= 6 )[ f()+4f (b )5 f (4) (ξ) 2880 Composite Simpson s rule: for some ξ [, b] ( ) + b 2 ] + f(b) f(x) dx= h 3 [f 0 +4f 1 +2f 2 +4f 3 + +4f n 1 + f n ] h4 (b ) f (4) (ξ) 180 Obscure rules for degree 3, 4, etc. pproximtions. 7
Gussin Formuls All integrtion formuls re of form f(x) dx. = for some qudrture nodes x i [, b] nd qudrture weights ω i. Newton-Cotes use rbitrry x i Gussin qudrture uses good choices of x i nodes nd ω i weights. Exct qudrture formuls: Let F k be the spce of degree k polynomils n ω i f(x i ) (7.2.1) A qudrture formul is exct of degree k if it correctly integrtes ech function in F k Gussin qudrture formuls use n points nd re exct of degree 2n 1 8
Theorem 1 Suppose tht {ϕ k (x)} k=0 on [, b]. is n orthonorml fmily of polynomils with respect to w(x) 1. Define q k so tht ϕ k (x) =q k x k +. 2. Let x i, i =1,..., n be the n zeros of ϕ n (x) 3. Let ω i = Then q n+1 /q n ϕ n(x i ) ϕ n+1 (x i ) > 0 1. <x 1 <x 2 < <x n <b; 2. if f C (2n) [, b], then for some ξ [, b], w(x) f(x) dx = n ω i f(x i )+ f (2n) (ξ) q 2 n(2n)! ; 3. nd n ω if(x i ) is the unique formul on n nodes tht exctly integrtes f(x) w(x) dx for ll polynomils in F 2n 1. 9
Guss-Chebyshev Qudrture Domin: [ 1, 1] Weight: (1 x 2 ) 1/2 Formul: 1 f(x)(1 x 2 ) 1/2 dx = π 1 n for some ξ [ 1, 1], with qudrture nodes ( 2i 1 x i = cos 2n n f(x i )+ π f (2n) (ξ) 2 2n 1 (2n)! (7.2.4) ) π, i =1,..., n. (7.2.5) 10
Arbitrry Domins Wnt to pproximte f(x) dx Different rnge, no weight function Liner chnge of vribles x = 1+2(y )(b ) Multiply the integrnd by (1 x 2 ) 1/2 / (1 x 2 ) 1/2. C.O.V. formul f(y) dy = b 2 1 1 f ( (x +1)(b ) 2 ) ( ) 1 x 2 1/2 + dx (1 x 2 1/2 ) Guss-Chebyshev qudrture produces f(y) dy =. π(b ) n ( ) (xi +1)(b ) (1 f + x 2 i 2n 2 where the x i re Guss-Chebyshev nodes over [ 1, 1]. ) 1/2 11
Guss-Legendre Qudrture Domin: [ 1, 1] Weight: 1 Formul: 1 for some 1 ξ 1. 1 f(x) dx = n ω i f(x i )+ 22n+1 (n!) 4 (2n +1)!(2n)! f (2n) (ξ) (2n)! Convergence: use n!. = e n 1 n n+1/2 2πn error bounded bove by π4 n M M =sup m Exponentil convergence for nlytic functions [ mx 1 x 1 f (m) ] (x) m! In generl, f(x) dx. = b 2 n ω i f ( (xi +1)(b ) 2 ) + 12
Use vlues for Gussin nodes nd weights from tbles insted of progrms; tbles will hve 16 digit ccurcy Tble 7.2: Guss Legendre Qudrture N x i ω i 2 ±0.5773502691 0.1000000000(1) 3 ±0.7745966692 0.5555555555 0 0.8888888888 5 ±0.9061798459 0.2369268850 ±0.5384693101 0.4786286704 0 0.5688888888 10 ±0.9739065285 0.6667134430( 1) ±0.8650633666 0.1494513491 ±0.6794095682 0.2190863625 ±0.4333953941 0.2692667193 ±0.1488743389 0.2955242247 13
Life-cycle exmple: c(t) =1+t/5 7(t/50) 2,where0 t 50. Discounted utility is 50 0 e ρt u(c(t)) dt ρ =0.05, u(c) =c 1+γ /(1 + γ). Errors in computing ( 50 0 e.05t 1+ t 5 7 ( ) t 2 1 γ 50) dt γ=.5 1.1 3 10 Truth 1.24431.664537.149431.0246177 Rule: GLeg 3 5(-3) 2(-3) 3(-2) 2(-2) GLeg 5 1(-4) 8(-5) 5(-3) 2(-2) GLeg 10 1(-7) 1(-7) 2(-5) 2(-3) GLeg 15 1(-10) 2(-10) 9(-8) 4(-5) GLeg 20 7(-13) 9(-13) 3(-10) 6(-7) 14
Guss-Hermite Qudrture Domin: [, ]] Weight: e x2 Formul: for some ξ (, ). f(x)e x2 dx = n ω i f(x i )+ n! π f (2n) (ξ) 2 n (2n)! 15
Tble 7.4: Guss Hermite Qudrture N x i ω i 2 ±0.7071067811 0.8862269254 3 ±0.1224744871(1) 0.2954089751 0 0.1181635900(1) 4 ±0.1650680123(1) 0.8131283544( 1) ±0.5246476232 0.8049140900 7 ±0.2651961356(1) 0.9717812450( 3) ±0.1673551628(1) 0.5451558281( 1) ±0.8162878828 0.4256072526 0 0.8102646175 10 ±0.3436159118(1) 0.7640432855( 5) ±0.2532731674(1) 0.1343645746( 2) ±0.1756683649(1) 0.3387439445( 1) ±0.1036610829(1) 0.2401386110 ±0.3429013272 0.6108626337 16
Norml Rndom Vribles Y is distributed N(μ, σ 2 ) Expecttion is integrtion: UseGuss-Hermitequdrture liner COV x =(y μ)/ 2 σ COV formul: COV qudrture formul: E{f(Y )} =(2πσ 2 ) 1/2 f(y)e (y μ)2 /(2σ 2) dy = E{f(Y )}. = π 1 2 f(y)e (y μ) 2 2σ 2 dy f( 2 σx+ μ)e x2 2 σdx n ω i f( 2 σx i + μ) where the ω i nd x i re the Guss-Hermite qudrture weights nd nodes over [, ]. 17
Portfolio exmple An investor holds one bond which will be worth 1 in the future nd equity whose vlue is Z, where ln Z N(μ, σ 2 ). Expected utility is U =(2πσ 2 ) 1/2 u(c)= c1+γ 1+γ nd the certinty equivlent of (7.2.12) is u 1 (U). Errors in certinty equivlents: Tble 7.5 u(1 + e z )e (z μ)2 /2σ 2 dz (7.2.12) Rule γ:.5 1.1-2.0-5.0-10.0 GH2 1(-4) 2(-4) 3(-4) 6(-3) 3(-2) GH3 1(-6) 3(-6) 9(-7) 7(-5) 9(-5) GH4 2(-8) 7(-8) 4(-7) 7(-6) 1(-4) GH7 3(-10) 2(-10) 3(-11) 3(-9) 1(-9) GH13 3(-10) 2(-10) 3(-11) 5(-14) 2(-13) The certinty equivlent of (7.2.12) with μ =0.15 nd σ =0.25 is 2.34. So, reltive errors re roughly the sme. 18
Guss-Lguerre Qudrture Domin: [0, ]] Weight: e x Formul: for some ξ [0, ). Generl integrl 0 f(x)e x dx = n ω i f(x i )+(n!) 2f(2n) (ξ) (2n)! Liner COV x = r(y ) COV formul e ry f(y) dy. = e r r n ω i f ( xi r + ) where the ω i nd x i re the Guss-Lguerre qudrture weights nd nodes over [0, ]. 19
Tble 7.6: Guss Lguerre Qudrture N x i ω i 2 0.5857864376 0.8535533905 0.3414213562(1) 0.1464466094 3 0.4157745567 0.7110930099 0.2294280360(1) 0.2785177335 0.6289945082(1) 0.1038925650( 1) 4 0.3225476896 0.6031541043 0.1745761101(1) 0.3574186924 0.4536620296(1) 0.3888790851( 1) 0.9395070912(1) 0.5392947055( 3) 7 0.1930436765 0.4093189517 0.1026664895(1) 0.4218312778 0.2567876744(1) 0.1471263486 0.4900353084(1) 0.2063351446( 1) 0.8182153444(1) 0.1074010143( 2) 0.1273418029(2) 0.1586546434( 4) 0.1939572786(2) 0.3170315478( 7) 20
Present Vlue Exmple Use Guss-Lguerre qudrture to compute present vlues. Suppose discounted profits equl ( ) η 1 η 1 η e rt m(t) 1 η dt. η Errors: Tble 7.7 0 r =.05 r =.10 r =.05 λ =.05 λ =.05 λ =.20 Truth: 49.7472 20.3923 74.4005 Errors: GLg 4 3(-1) 4(-2) 6(0) GLg 5 7(-3) 7(-4) 3(0) GLg 10 3(-3) 6(-5) 2(-1) GLg 15 6(-5) 3(-7) 6(-2) GLg 20 3(-6) 8(-9) 1(-2) Guss-Lguerre integrtion implicitly ssumes tht m(t) 1 η is polynomil. When λ =0.05, m(t) is nerly constnt When λ =0.20, m(t) 1 η is less polynomil-like. 21
Do-It-Yourself Gussin Formuls Question: Wht should you do if your problem does not fit one of the conventionl integrl problems? Answer: Crete your own Gussin formul! Theorem: Let w (x) be weight function on [, b], nd suppose tht ll moments exist; i.e., x i w (x) dx <, i =1, 2,... Then for ll n there exists qudrture nodes x i [, b] nd qudrture weights ω i such tht the pproximtion n f(x) w(x) dx = ω i f(x i ) is exct for ll degree 2n 1 polynomils. Algorithm to find formul: Construct the polynomil p (x) = x n + n 1 x n 1 + n 2 x n 2... + 0 nd pick the coefficients j to minimize the integrl p (x) 2 w(x) dx 22
The x i nodes re the zeros of p (x). The weights ω i re chosen to stisfy the liner equtions n x k w(x) dx = ω i x k i,k=0, 1,.., 2n 1 which is overdetermined but hs unique solution. 23
Generl Applicbility of Gussin Qudrture Theorem 2 (Gussin qudrture convergence) If f is Riemnn Integrble on [, b], the error in the n-point Guss-Legendre rule pplied to f(x) dx goesto0sn. Comprisons with Newton-Cotes formuls: Tble 7.1 Rule n 1 0 x1/4 dx 10 1 x 2 dx 1 0 ex dx 1 1 (x +.05) + dx Trpezoid 4 0.7212 1.7637 1.7342 0.6056 7 0.7664 1.1922 1.7223 0.5583 10 0.7797 1.0448 1.7200 0.5562 13 0.7858 0.9857 1.7193 0.5542 Simpson 3 0.6496 1.3008 1.4662 0.4037 7 0.7816 1.0017 1.7183 0.5426 11 0.7524 0.9338 1.6232 0.4844 15 0.7922 0.9169 1.7183 0.5528 G-Legendre 4 0.8023 0.8563 1.7183 0.5713 7 0.8006 0.8985 1.7183 0.5457 10 0.8003 0.9000 1.7183 0.5538 13 0.8001 0.9000 1.7183 0.5513 Truth.80000.90000 1.7183 0.55125 24
Multidimensionl Integrtion Most economic problems hve severl dimensions Multiple ssets Multiple error terms Multidimensionl integrls re much more difficult Simple methods suffer from curse of dimensionlity There re methods which void curse of dimensionlity 25
Product Rules Build product rules from one-dimension rules Let x l i,ω l i, i =1,,m, be one-dimensionl qudrture points nd weights in dimension l from Newton-Cotes rule or the Guss-Legendre rule. The product rule [ 1,1] d f(x)dx. = m m i 1 =1 i d =1 ω 1 i 1 ω 2 i 2 ω d i d f(x 1 i 1,x 2 i 2,,x d i d ) Gussin structure previls Suppose w l (x) is weighting function in dimension l Define the d-dimensionl weighting function. d W(x) W(x 1,,x d )= w l (x l ) Product Gussin rules re bsed on product orthogonl polynomils. Curse of dimensionlity: m d functionl evlutions is m d for d-dimensionl problem with m points in ech direction. Problem worse for Newton-Cotes rules which re less ccurte in R 1. l=1 26
Monomil Formuls: A Nonproduct Approch Method Choose x i D R d,,..., N Choose ω i R,,..., N Qudrture formul D f(x) dx. = A monomil formul is complete for degree l if N ω i p(x i )= N D ω i f(x i ) (7.5.3) p(x) dx (7.5.3) for ll polynomils p(x) of totl degree l; recll tht P l wsdefinedinchpter6tobethesetof such polynomils. For the cse l =2, this implies the equtions N ω i = D 1 dx N ω ix i j = D x j dx, j =1,,d N ω ix i jx i k = D x jx k dx, j, k =1,,d (7.5.4) 1+d + 1 2d(d +1)equtions N weights ω i nd the N nodes x i ech with d components, yielding totl of (d +1)N unknowns. 27
Qudrture Node Sets Nturl types of nodes: The center The circles: centers of fces The strs: centers of edges The squres: vertices 28
Simple exmples Let e j (0,...,1,...,0) where the 1 ppers in column j. 2d points nd exctly integrtes ll elements of P 3 over [ 1, 1] d [ 1,1] d f. =ω u= d ( f(ue i )+f( ue i ) ) ( ) 1/2 d,ω= 2d 1 3 d For P 5 the following scheme works: [ 1,1] f. =ω d 1 f(0) + ω d ( 2 f(ue i )+f( ue i ) ) ( +ω 3 1 i<d, f(u(e i ± e j )) + f( u(e i ± e j )) ) i<j d where ω 1 =2 d (25 d 2 115 d + 162), ω 2 =2 d (70 25d) ω 3 = 25 324 2d, u =( 3 5 )1/2. 29