3469 - Practical Numerical Simulations Mike Peardon — mjp@maths.tcd.ie http://www.maths.tcd.ie/~mjp/3469 School of Mathematics Trinity College Dublin Michaelmas Term 2015 Mike Peardon — mjp@maths.tcd.ie http://www.maths.tcd.ie/~mjp/3469 3469 (TCD) Michaelmas Term 2015 1/8 Numerical solutions to ODEs 2. Boundary-value problems Mike Peardon — mjp@maths.tcd.ie http://www.maths.tcd.ie/~mjp/3469 3469 (TCD) Michaelmas Term 2015 2/8 Boundary-value problems So far, have considered solving ODEs with boundary conditions of the form (0) (1) (2) x(t0 ) = x0 , ẋ(t0 ) = x0 , ẍ(t0 ) = x0 , . . . Techniques start with these values, then propagate the solution to t0 + h, t0 + 2h, t0 + 3h, . . . . Consider now case where the N boundary data are specified at two distinct places, t0 , t1 . A general boundary value problem Solve an Nth-order ODE (with x (0) = x, x (1) = ẋ, . . . ) with boundary data of the form ga (x(t0 )) = 0 for a = 1 . . . n hb (x(t1 )) = 0 for b = n . . . N Mike Peardon — mjp@maths.tcd.ie http://www.maths.tcd.ie/~mjp/3469 3469 (TCD) Michaelmas Term 2015 3/8 Shooting method Do not now have the data to start our iterative scheme. Example: second-order ODE with x given at two end-points x is known at two distinct points, t0 and t1 , so x(t0 ) = x0 , x(t1 ) = x1 Initial-value solver needs data on ẋ(t0 ) to start, so guess a value: ẋ(t0 ) = c Now we have initial value data (although probably solving the wrong problem!), so can use Euler, Runge-Kutta etc. Solve to find x̄(t1 ; c), the approximate solution at t1 given c. Determine the value of c for which the other boundary condition x(t1 ) = x1 holds. Mike Peardon — mjp@maths.tcd.ie http://www.maths.tcd.ie/~mjp/3469 3469 (TCD) Michaelmas Term 2015 4/8 Finding consistent initial data For general case, need N − n “fake” initial values for c Will need to solve N − n equations for these unknowns. In general, don’t known how many solutions there are (and there could be none). Finding the N − n consistent data can be challenging: use Newton-Rapheson or bisection for a single missing value, c. Newton-Rapheson needs information about dx/dc, which might be hard to come by. Bisection can miss solutions, needs help with good guesses for locations of solutions, etc. Mike Peardon — mjp@maths.tcd.ie http://www.maths.tcd.ie/~mjp/3469 3469 (TCD) Michaelmas Term 2015 5/8 Example from Stoer and Bulirsch Boundary-value 2nd-order ODE 3 2 x 2 with x(0) = 4, x(1) = 1 ẍ = Solve instead the ODE with initial data: x(0) = 4, ẋ(0) = c and examine b(c) = x(1; c) − 1 for zeroes. Mike Peardon — mjp@maths.tcd.ie http://www.maths.tcd.ie/~mjp/3469 3469 (TCD) Michaelmas Term 2015 6/8 Example from Stoer and Bulirsch 60 b(c) 40 20 0 -100 -80 -60 -40 Guessed initial data, c -20 0 Find two consistent solutions, c ≈ −35.9, −8.0 Mike Peardon — mjp@maths.tcd.ie http://www.maths.tcd.ie/~mjp/3469 3469 (TCD) Michaelmas Term 2015 7/8 Example from Stoer and Bulirsch The two solutions are then: 5 x(0)=4 x(1)=1 x(t) 0 -5 -10 0 0.2 0.4 0.6 0.8 1 t Mike Peardon — mjp@maths.tcd.ie http://www.maths.tcd.ie/~mjp/3469 3469 (TCD) Michaelmas Term 2015 8/8