# UMD ASTR 415 - Numerical Integration (3 pages)

Previewing page 1 of 3 page document
View Full Document

## Numerical Integration

Previewing page 1 of actual document.

View Full Document
View Full Document

## Numerical Integration

81 views

Pages:
3
School:
University of Maryland, College Park
Course:
Astr 415 - Computational Astrophysics
##### Computational Astrophysics Documents
Unformatted text preview:

Class 13 Numerical Integration Simple Monte Carlo Integration NRiC 7 6 Can use RNGs to estimate integrals Suppose we pick n random points x1 xN uniformly in a multi D volume V Basic theorem of Monte Carlo integration Z V f dV V f V where f s f 2 f 2 N N N 1 X 1 X f xi and f 2 f 2 xi N i 1 N i 1 The term is a 1 error estimate not a rigorous bound Previous formula works fine if V is simple What if we want to integrate a function g over a region W that is not easy to sample randomly Solution find a simple volume V that encloses W and define a new function f x x V such that g x for all x W f x 0 otherwise E g suppose we want to integrate g x y over the shaded area inside area A below Area A b x To integrate take random samples over the whole rectangle set f xi yi g xi yi yi b xi 0 otherwise and compute Z shaded area g x y dx dy 1 AX f xi yi N i Nifty example can be estimated by integrating p x y 1 x2 y 2 1 0 otherwise 1 Z over a 2 2 square Z 1 1 p x y dx dy 1 4 X p xi yi N i See NRiC for another worked example Optimization strategy make V as close as possible to W since zero values of f will increase the relative error estimate Principal disadvantage accuracy increases only as square root of N Fancier routines exist for faster convergence NRiC 7 7 7 8 Monte Carlo techniques used in a variety of other contexts anywhere statistical sampling is useful E g Predicting motion of bodies with short Lyapunov times if starting positions and velocities poorly known Determining model fit significance by testing the model against many sets of random synthetic data with the same mean and variance Numerical Integration Quadrature NRiC 4 Already seen Monte Carlo integration Can cast problem as a differential equation DE I Z b a f x dx is equivalent to solving for I y b the DE dy dx f x with the boundary condition BC y a 0 Will learn about ODE solution methods next class 2 Trapezoidal and Simpson s rules Have abscissas xi x0 ih i 0 1 N 1 A function f x has known values f xi fi Want to integrate f x between endpoints a and b Trapezoidal rule 2 point closed formula Z x2 f x dx h x1 1 1 f1 f2 O h3 f 00 2 2 i e the area of a trapezoid of base h and vertex heights f1 and f2 Simpson s rule 3 point closed formula Z x3 x1 f x dx h 4 1 1 f1 f2 f3 O h5 f 4 3 3 3 Extended trapezoidal rule If we apply the trapezoidal rule N 1 times and add the results we get Z xN x1 1 b a 3 f 00 1 f x dx h f1 f2 f3 fN 1 fN O 2 2 N2 Big advantage is it builds on previous work Coarsest step average f at endpoints a and b Next refinement add value at midpoint to average Next add values at 1 4 and 3 4 points And so on This is implemented as trapzd in NRiC More sophistication Usually don t know N in advance so iterate to a desired accuracy qtrap Higher order method by cleverly adding refinements to cancel error terms qsimp Generalization to order 2k Richardson s deferred approach to the limit qromb Uses extrapolation methods to set h 0 For improper integrals generally need open formulae not evaluated at endpoints For multi D use nested 1 D techniques 3

View Full Document

## Access the best Study Guides, Lecture Notes and Practice Exams Unlocking...
Sign Up

Join to view Numerical Integration and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?