GaussianGaussian QuadraturesQuadratures • Newton-Cotes Formulae – use evenly-spaced functional values – Did not use the flexibility we have to select the quadrature points • In fact a quadrature point has several degrees of freedom. m Q(f)=∑i=1 ci f(xi) A formula with m evaluations requires specification of 2m numbers ci and xi • Gaussian Quadratures – select both these weights and locations so that a higher order can be integrated (alternatively the error is proportional to a higher derivatives) • Price: functional values must now be evaluated at non- uniformly distributed points to achieve higher accuracy • Weights are no longer simple numbers • Usually derived for an interval such as [-1,1] • Other intervals [a,b] determined by mapping to [-1,1] Gaussian Quadrature on [-1, 1]

1 n f ( x )dx ≈ ci f ( xi ) = c1 f ( x1 ) + c2 f ( x 2 ) + + cn f ( xn ) ∫−1 ∑ L i=1 • Two function evaluations: – Choose (c1, c2, x1, x2) such that the method yields “exact ” for f(x) = x0, x1, x2, x3

1 n = 2 : f(x)dx ∫−1

= c1 f(x1 ) + c2 f(x2 )

-1x1 x2 1 Finding quadrature nodes and weights

• One way is through the theory of orthogonal . • Here we will do it via brute force • Set up equations by requiring that the 2m points guarantee that a polynomial of degree 2m-1 is integrated exactly. • In general process is non-linear – (involves a polynomial function involving the unknown point and its product with unknown weight) – Can be solved by using a multidimensional nonlinear solver – Alternatively can sometimes be done step by step GaussianGaussian QuadratureQuadrature onon [[--1,1, 1]1] 1 n = 2 : f(x)dx = c1 f(x1 ) + c2 f(x2 ) ∫−1 Exact integral for f = x0, x1, x2, x3 – Four equations for four unknowns ⎧ 1 f = 1 ⇒ 1dx = 2 = c1 + c2 ⎧c1 = 1 ⎪ ∫−1 ⎪c = 1 ⎪ 1 ⎪ 2 f = x ⇒ xdx = 0 = c1 x1 + c2 x2 ⎪ ∫−1 ⎪ − 1 x = ⎨ 1 ⇒ ⎨ 1 2 2 2 2 2 3 ⎪ f = x ⇒ x dx = = c1 x1 + c2 x2 ⎪ ∫−1 ⎪ 3 ⎪ 1 1 x = ⎪ 3 3 3 3 ⎪ 2 f = x ⇒ x dx = 0 = c1 x1 + c2 x2 3 ⎩ ∫−1 ⎩

1 1 1 I = f ( x )dx = f ( − ) + f ( ) ∫−1 3 3 Error

• If we approximate a function with a Gaussian quadrature formula we cause an error proportional to 2n th derivative GaussianGaussian QuadratureQuadrature onon [[--1,1, 1]1]

1 n = 3 : f ( x )dx = c1 f ( x1 ) + c2 f ( x2 ) + c3 f ( x3 ) ∫−1

-1x1 x2 x3 1

• Choose (c1, c2, c3, x1, x2,x3) such that the method yields “exact integral” for f(x) = x0, x1, x2, x3,x4, x5 GaussianGaussian QuadratureQuadrature onon [[--1,1, 1]1] 1 f =1⇒ xdx = 2 = c + c + c ∫ 1 2 3 −1 1 f = x ⇒ xdx = 0 = c x + c x + c x ∫ 1 1 2 2 3 3 −1 ⎧c1 = 5/ 9 1 ⎪ 2 c2 = 8/ 9 f = x2 ⇒ x2dx = = c x2 + c x2 + c x2 ⎪ ∫ 1 1 2 2 3 3 ⎪c = 5/ 9 −1 3 ⎪ 3 ⇒ ⎨ 1 x = − 3/ 5 f = x3 ⇒ x3dx = 0 = c x3 + c x3 + c x3 ⎪ 1 ∫ 1 1 2 2 3 3 ⎪x = 0 −1 ⎪ 2 1 2 ⎪x = 3/ 5 f = x4 ⇒ x4dx = = c x4 + c x4 + c x4 ⎩ 3 ∫ 1 1 2 2 3 3 −1 5 1 f = x5 ⇒ x5dx = 0 = c x5 + c x5 + c x5 ∫ 1 1 2 2 3 3 −1 GaussianGaussian QuadratureQuadrature onon [[--1,1, 1]1]

Exact integral for f = x0, x1, x2, x3, x4, x5

1 5 3 8 5 3 I = f ( x )dx = f ( − ) + f ( 0 ) + f ( ) ∫−1 9 5 9 9 5 GaussianGaussian QuadratureQuadrature onon [a,[a, b]b]

Coordinate transformation from [a,b] to [-1,1]

b − a b + a t = x + 2 2 ⎧x = −1 ⇒ t = a ⎨ ⎩x = 1 ⇒ t = b

abt1 t2

b 1 b − a b + a b − a 1 f ( t )dt = f ( x + )( )dx = g( x )dx ∫a ∫−1 2 2 2 ∫−1 Example:Example: GaussianGaussian QuadratureQuadrature 4 Evaluate I = te 2t dt = 5216.926477 ∫0 Coordinate transformation b − a b + a t = x + = 2x + 2; dt = 2dx 2 2 4 1 1 I = te2t dt = (4x + 4)e4x+4dx = f (x)dx ∫0 ∫−1 ∫−1 Two-point formula

4 4 1 − 1 1 4 4− 4 4+ I = f ( x )dx = f ( ) + f ( ) = ( 4 − )e 3 + ( 4 + )e 3 ∫−1 3 3 3 3 = 9.167657324 + 3468.376279 = 3477.543936 (ε = 33.34%) Example:Example: GaussianGaussian QuadratureQuadrature Three-point formula 1 5 8 5 I = f ( x )dx = f ( − 0.6 ) + f ( 0 ) + f ( 0.6 ) ∫−1 9 9 9 5 8 5 = ( 4 − 4 0.6 )e 4− 0.6 + ( 4 )e 4 + ( 4 + 4 0.6 )e 4+ 0.6 9 9 9 5 8 5 = ( 2.221191545 ) + ( 218.3926001 ) + ( 8589.142689 ) 9 9 9 = 4967.106689 (ε = 4.79%) Four-point formula

1 I = f ( x )dx = 0.34785[]f ( −0.861136 ) + f ( 0.861136 ) ∫−1 + 0.652145 []f ( −0.339981 ) + f ( 0.339981 ) = 5197.54375 (ε = 0.37%) Other rules

• Gauss-Lobatto: – requiring end points be included in the formula • Gauss-Radau – Require one end point be in the formula