Computational Methods in Physics PHYS 3437 Dr Rob Thacker Dept of Astronomy & Physics (MM-301C)

Slides:



Advertisements
Similar presentations
Calculus Weeks 3&4. Integration by parts This is another way to try and integrate products. It is in fact the opposite of the product rule for derivatives:
Advertisements

Computational Methods in Physics PHYS 3437
INFINITE SEQUENCES AND SERIES
Computational Methods in Physics PHYS 3437
Applications of Differentiation
7 INVERSE FUNCTIONS.
Today’s class Romberg integration Gauss quadrature Numerical Methods
Computational Methods in Physics PHYS 3437
ASYMPTOTIC PROPERTIES OF ESTIMATORS: PLIMS AND CONSISTENCY
Copyright © Cengage Learning. All rights reserved. 14 Further Integration Techniques and Applications of the Integral.
Infinite Sequences and Series
INFINITE SEQUENCES AND SERIES
Math Calculus I August 9 (but first, a quick review…)
Lecture 3: Integration. Integration of discrete functions
8 TECHNIQUES OF INTEGRATION. In defining a definite integral, we dealt with a function f defined on a finite interval [a, b] and we assumed that f does.
TECHNIQUES OF INTEGRATION
Constrained Optimization
CHAPTER 4 THE DEFINITE INTEGRAL.
Notes, part 5. L’Hospital Another useful technique for computing limits is L'Hospital's rule: Basic version: If, then provided the latter exists. This.
Notes, part 4 Arclength, sequences, and improper integrals.
Math Calculus I Part 8 Power series, Taylor series.
12 INFINITE SEQUENCES AND SERIES The Comparison Tests In this section, we will learn: How to find the value of a series by comparing it with a known.
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM.
Computational Methods in Physics PHYS 3437 Dr Rob Thacker Dept of Astronomy & Physics (MM-301C)
Ch 8.1 Numerical Methods: The Euler or Tangent Line Method
Buffon’s Needle Todd Savage. Buffon's needle problem asks to find the probability that a needle of length ‘l’ will land on a line, given a floor with.
Simulation of Random Walk How do we investigate this numerically? Choose the step length to be a=1 Use a computer to generate random numbers r i uniformly.
Integration of irrational functions
Techniques of Integration
BY PARTS. Integration by Parts Although integration by parts is used most of the time on products of the form described above, it is sometimes effective.
APPLICATIONS OF INTEGRATION 6. A= Area between f and g Summary In general If.
ME 2304: 3D Geometry & Vector Calculus Dr. Faraz Junejo Double Integrals.
Chapter 1 Infinite Series, Power Series
Chapter 9 Numerical Integration Flow Charts, Loop Structures Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
CISE301_Topic11 CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4:
Absolute vs. Conditional Convergence Alternating Series and the Alternating Series Test.
APPLICATIONS OF DIFFERENTIATION Indeterminate Forms and L’Hospital’s Rule APPLICATIONS OF DIFFERENTIATION In this section, we will learn: How to.
Section 4.4 Indeterminate Forms and L’Hospital’s Rule Applications of Differentiation.
Copyright © Cengage Learning. All rights reserved. 4 Applications of Differentiation.
Guillaume De l'Hôpital Actually, L’Hôpital’s Rule was developed by his teacher Johann Bernoulli. De L’Hôpital paid Bernoulli for private lessons,
8.4 Improper Integrals AP Calculus BC. 8.4 Improper Integrals One of the great characteristics of mathematics is that mathematicians are constantly finding.
Moving to three dimensions we will need new, more complicated, coordinate systems separation of variables is the key method for breaking down a problem.
1 Lesson 8: Basic Monte Carlo integration We begin the 2 nd phase of our course: Study of general mathematics of MC We begin the 2 nd phase of our course:
Summation Notation Also called sigma notation
DERIVATIVES 3. If it were always necessary to compute derivatives directly from the definition, as we did in the Section 3.2, then  Such computations.
11.2 Series In this section, we will learn about: Various types of series. INFINITE SEQUENCES AND SERIES.
Computational Methods in Physics PHYS 3437 Dr Rob Thacker Dept of Astronomy & Physics (MM-301C)
Summation Notation Also called sigma notationAlso called sigma notation (sigma is a Greek letter Σ meaning “sum”) The series can be written.
College Algebra Sixth Edition James Stewart Lothar Redlin Saleem Watson.
In section 11.9, we were able to find power series representations for a certain restricted class of functions. Here, we investigate more general problems.
Numerical Methods.
Section 7.7 Improper Integrals. So far in computing definite integrals on the interval a ≤ x ≤ b, we have assumed our interval was of finite length and.
12 INFINITE SEQUENCES AND SERIES. In general, it is difficult to find the exact sum of a series.  We were able to accomplish this for geometric series.
AUGUST 2. MATH 104 Calculus I Review of previous material…. …methods and applications of integration, differential equations ………..
Advanced Engineering Mathematics, 7 th Edition Peter V. O’Neil © 2012 Cengage Learning Engineering. All Rights Reserved. CHAPTER 4 Series Solutions.
Copyright © Cengage Learning. All rights reserved.
Boyce/DiPrima 9 th ed, Ch 11.3: Non- Homogeneous Boundary Value Problems Elementary Differential Equations and Boundary Value Problems, 9 th edition, by.
INFINITE SEQUENCES AND SERIES The convergence tests that we have looked at so far apply only to series with positive terms.
6.1 Areas Between Curves In this section we learn about: Using integrals to find areas of regions that lie between the graphs of two functions. APPLICATIONS.
INFINITE SEQUENCES AND SERIES In general, it is difficult to find the exact sum of a series.  We were able to accomplish this for geometric series and.
Trigonometric Identities
Lesson 8: Basic Monte Carlo integration
5.5 Trapezoidal Rule.
CHAPTER 19 Series and Residues.
Chapter 1 Infinite Series, Power Series
SKTN 2393 Numerical Methods for Nuclear Engineers
APPROXIMATE INTEGRATION
APPROXIMATE INTEGRATION
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
Presentation transcript:

Computational Methods in Physics PHYS 3437 Dr Rob Thacker Dept of Astronomy & Physics (MM-301C)

Today’s lecture Challenges in numerical integration Challenges in numerical integration Using a change of variables Using a change of variables Dealing with singularities & improper integrals Dealing with singularities & improper integrals Multidimensional integration Multidimensional integration

Change of variables: motivation Romberg integration works especially well when f´(a)=f´(b) since the first error term must cancel Romberg integration works especially well when f´(a)=f´(b) since the first error term must cancel However, if derivatives become infinite at the end points there can be trouble converging However, if derivatives become infinite at the end points there can be trouble converging x y

Apply a change of variables All odd derivatives are zero – we can expect the trapezoid rule to be very accurate! All odd derivatives are zero – we can expect the trapezoid rule to be very accurate! In fact it gives the exact answer with just 2 zones! In fact it gives the exact answer with just 2 zones!

Check for convergence: Romberg Ratio The Romberg integrator needs to know whether things are converging or not The Romberg integrator needs to know whether things are converging or not Define the Romberg ratio: Define the Romberg ratio: So provided this ratio stays around 4 things are converging as they should So provided this ratio stays around 4 things are converging as they should If Rt j <3.5 (say) then that is a signal things are not converging and we need to check some things… If Rt j <3.5 (say) then that is a signal things are not converging and we need to check some things…

Check derivatives First thing to check is the first derivatives at x=a & x=b First thing to check is the first derivatives at x=a & x=b If large or infinite then a change of variables is probably necessary If large or infinite then a change of variables is probably necessary It is possible that you may hit a point where f´(a), f´(b), f´´´(a), f´´´(b) are still well behaved but convergence is slow It is possible that you may hit a point where f´(a), f´(b), f´´´(a), f´´´(b) are still well behaved but convergence is slow In this case you force you integrator to proceed but keep a check on the interim results In this case you force you integrator to proceed but keep a check on the interim results Eventually if there is convergence you will get back to a Romberg ratio of Rt j ~4 Eventually if there is convergence you will get back to a Romberg ratio of Rt j ~4

Example: Pendulum without small angle approximation Along x direction: Along x direction: Since dx=ld  we get Since dx=ld  we get  Period T mg  a y x l Note under small angle approx sin  →  to give a solution:

Rewriting as an integral Eqn (1) is a second order ODE which we could solve using a numerical ODE solver Eqn (1) is a second order ODE which we could solve using a numerical ODE solver However we can turn this particular problem into an integral as follows: However we can turn this particular problem into an integral as follows:

Further manipulation

Immediate problems This is an elliptic integral of the first kind and must be evaluated numerically – however the upper limit produces a singularity so change variables: This is an elliptic integral of the first kind and must be evaluated numerically – however the upper limit produces a singularity so change variables:

Change of variables to  Here are all the steps: Here are all the steps:

Arrive at numerically tractable integral After cancelling like terms in the numerator & denominator we get After cancelling like terms in the numerator & denominator we get (3) is a perfectly well behaved function: there are no issues at the end points or the interior (k=1 is impossible since k=sin(  0 /2) and  0 <  /2) (3) is a perfectly well behaved function: there are no issues at the end points or the interior (k=1 is impossible since k=sin(  0 /2) and  0 <  /2) Thus amenable to numerical (e.g. Romberg) integration Thus amenable to numerical (e.g. Romberg) integration Note that the integral of the form Note that the integral of the form is called a complete elliptic integral of the first kind and can be found tabulated for various k

Improper integrals Thus far we have considered only definite integrals with finite limits, what about Thus far we have considered only definite integrals with finite limits, what about Firstly, if I is divergent then a numerical integration is pointless Firstly, if I is divergent then a numerical integration is pointless If I is convergent we must still handle the upper limit somehow If I is convergent we must still handle the upper limit somehow There are two ways of handling this type of integral There are two ways of handling this type of integral Break up the integral into two parts Break up the integral into two parts Use a single change of variables to make the limits tractable Use a single change of variables to make the limits tractable

Split the integral Write Write The value of a needs to be chosen with care The value of a needs to be chosen with care I 1 we can evaluate numerically, with say a Romberg integrator (provided f is finite everywhere!) I 1 we can evaluate numerically, with say a Romberg integrator (provided f is finite everywhere!) For I 2 we apply a change of variables to turn the integral into one with finite limits For I 2 we apply a change of variables to turn the integral into one with finite limits Proper integral, I 1 Improper integral, I 2

Change of variables Provided f(1/y)~y n & n>1 then there are no singularities in the integrand and we can apply Romberg integration Provided f(1/y)~y n & n>1 then there are no singularities in the integrand and we can apply Romberg integration This is a reasonable expectation. We really asking for asymptotic behaviour of f(x)~1/x 2 or lower. Without a fairly rapid approach to zero we wouldn’t expect the integral to be bounded. This is a reasonable expectation. We really asking for asymptotic behaviour of f(x)~1/x 2 or lower. Without a fairly rapid approach to zero we wouldn’t expect the integral to be bounded.

Removable singularities It is still possible that after our substitution we wind up with removable singularities It is still possible that after our substitution we wind up with removable singularities Consider Consider However, when you calculate sin 0/0 the computer will give a divide by zero error However, when you calculate sin 0/0 the computer will give a divide by zero error There is clearly no “magic algorithm” that works in all cases There is clearly no “magic algorithm” that works in all cases Different substitutions may be required, series expansions may be necessary or even other methods be employed before invoking numerical integration Different substitutions may be required, series expansions may be necessary or even other methods be employed before invoking numerical integration

Other useful substitutions Notice that both these substitutions can be used on the entire range [0,∞) – there is no need to break up the integral Notice that both these substitutions can be used on the entire range [0,∞) – there is no need to break up the integral It may be the case though that it is better to do this for numerical convergence reasons It may be the case though that it is better to do this for numerical convergence reasons

Singularities in the integrand Our primary concern is I 1 due to the singularity at 0 Our primary concern is I 1 due to the singularity at 0 Firstly though, let’s look at I 2 and how we would approach that Firstly though, let’s look at I 2 and how we would approach that I1I1 I2I2

Try substitutions in I 2 The latter example is perfectly well behaved (no singularities in [0,1/√a]) The latter example is perfectly well behaved (no singularities in [0,1/√a]) So we can deal with I 2 without a problem So we can deal with I 2 without a problem

Approaches to help us integrate I 1 Use another substitution Use another substitution Can do a power series expansion Can do a power series expansion Not covered here, but see p. 166,167 of? Not covered here, but see p. 166,167 of? We may be able to isolate the singularity (say by using a partial fraction expansion) We may be able to isolate the singularity (say by using a partial fraction expansion) We’ll look at both substitution (again) and isolation We’ll look at both substitution (again) and isolation

Substitution We have removed the singularity and the result can easily be calculated via Romberg integration We have removed the singularity and the result can easily be calculated via Romberg integration

Isolation

What to take away from this… Every integral will be different Every integral will be different You must be prepared to handle each one individually! You must be prepared to handle each one individually!

Multidimensional Numerical Integration At first it seems a straightforward extension of 1d ideas At first it seems a straightforward extension of 1d ideas However, if in 1d we needed say a 100 function evaluations 2d will require 100×100! However, if in 1d we needed say a 100 function evaluations 2d will require 100×100! 3d 100×100×100… etc 3d 100×100×100… etc Quickly gets very numerically expensive – sometimes we have to resort to guestimating using Monte Carlo methods Quickly gets very numerically expensive – sometimes we have to resort to guestimating using Monte Carlo methods Secondly, multidimensional integrals often have unusual boundaries Secondly, multidimensional integrals often have unusual boundaries Defining the limits may be tricky Defining the limits may be tricky As a first step lets consider integration over a rectangle As a first step lets consider integration over a rectangle

Simple 2d integration Thus there are two “sweeps” Thus there are two “sweeps” 1d integrator evaluates F(y) from f(x,y) (clearly we must do this for all values of y) 1d integrator evaluates F(y) from f(x,y) (clearly we must do this for all values of y) 1d integrator evaluates I from F(y) 1d integrator evaluates I from F(y)

2d integration illustrated This diagram shows precisely how the “sweeps” come about This diagram shows precisely how the “sweeps” come about There are N x-sweeps followed by a single y sweep There are N x-sweeps followed by a single y sweep We of course could do things the other way round We of course could do things the other way round i.e. y-sweeps before the x- sweeps: i.e. y-sweeps before the x- sweeps: d c x y a b f(x,y)

Other integration limits (in 2d) You may frequently encounter integrals defined by a curve in the x-y plane You may frequently encounter integrals defined by a curve in the x-y plane a x y y

In polar coordinates This particular problem strongly favours a change of variables: This particular problem strongly favours a change of variables:

Change of limits The limits are obvious here: The limits are obvious here: Note that while the limits in x & y are from 0 to a respectively so that Note that while the limits in x & y are from 0 to a respectively so that y a x

Summary These examples have shown that numerical integration needs to be treated with care These examples have shown that numerical integration needs to be treated with care Examine behaviour at end points, apply changes of variables if needs be Examine behaviour at end points, apply changes of variables if needs be Improper integrals can be handled by Improper integrals can be handled by Changes of variables Changes of variables Breaking up the integral into separate parts Breaking up the integral into separate parts Multidimensional integration is considerably more computational expensive Multidimensional integration is considerably more computational expensive

Next lecture Introduction to ODE solvers Introduction to ODE solvers