Solving Systems of ODEs in Python: From scalar to TOV. MP 10/2011

Size: px
Start display at page:

Download "Solving Systems of ODEs in Python: From scalar to TOV. MP 10/2011"

Transcription

1 Solving Systems of ODEs in Python: From scalar to TOV. MP 10/2011

2 Homework: Integrate a scalar ODE in python y (t) =f(t, y) = 5ty 2 +5/t 1/t 2 y(1) = 1 Integrate the ODE using using the explicit Euler method: y n+1 = y n + hf(t n,y n ) up to t=25 with various fixed step sizes h and record the absolute error e h (h) :=y n y(t n ) y 1 =1 between the numerical approximation and the exact solution at the end of the interval for each step size. Integrate the ODE with the explicit trapezoidal Runge Kutta 2 method k 1 = hf(t n,y n ) k 2 = hf(t n+1,y n + k 1 ) y n+1 = y n (k 1 + k 2 ) as above for various step sizes and compute the absolute error: y(t) =1/t

3 Homework: Integrate a scalar a scalar ODE ODE in python in python Compute a convergence rate for each method: If the error at step n behaves like e n (h) =y n y(t n ) Ch p then halving the step size yields e 2n (h/2) C(h/2) p Thus, the convergence rate can be obtained as p log 2 en (h) e 2n (h/2) Interpret the results! Which method is better? Make your program modular by dividing it into functions that can be reused Bonus: make the program work for integrating a set of different initial conditions at the same time

4 Homework: Integrate a scalar a scalar ODE ODE in python in python Simple Solution import matplotlib.pyplot as plt import numpy as np def EulerStep(u,t,dt,rhs): up = u + dt*rhs(u, t) return up # Asher / Petzold ex. 4.1 def rhs(u,t): return -5*t*u**2 + 5./t - 1./t**2 # now setup parameters, initial data and integrate the ODE t0 = 1.0 tend = 25.0 u = 1. nsteps = 500 dt = (tend-t0) / nsteps sol = np.zeros(nsteps) # to store the solution n=0 t=t0 while n < nsteps: sol[n] = u u = EulerStep(u,t,dt,rhs) n+=1 t+=dt # plot the result ts=np.linspace(t0,tend,nsteps) plt.plot(ts,sol) plt.show()

5 Homework: Integrate a scalar a scalar ODE ODE in python in python Improved Solution (part 1) import matplotlib.pyplot as plt import numpy as np def EulerStep(u,t,dt,rhs): up=u + dt*rhs(u, t) return up def RK2Step(u,t,dt,rhs): k1 = dt*rhs(u,t) k2 = dt*rhs(u + k1, t + dt) up = u + 0.5*(k1 + k2) return up # now setup parameters, initial data # and integrate the ODE def toyint(method, dt): t0 = 1.0 tend = 25.0 u = 1.0 nsteps = int((tend-t0) / dt) sol = [u] n=0 t=t0 while n < nsteps: u = method(u,t,dt,rhs) sol.append(u) n+=1 t+=dt # Asher / Petzold ex. 4.1 def rhs(u,t): return -5*t*u**2 + 5./t - 1./t**2 ts=np.linspace(t0,tend,nsteps) return (ts, sol) def yex(t): return 1./t

6 Homework: Integrate a scalar a scalar ODE ODE in python in python Improved Solution (part 2) def test(method, h): (ti,yi) = toyint(method, h) err = abs(yi[-1] - yex(ti[-1])) (ti2,yi2) = toyint(method, h/2) err2 = abs(yi2[-1] - yex(ti2[-1])) p = np.log2(err / err2) return (err, p) if name == " main ": # now we can import this file as a module without # running 'main', or execute it as a script hlist = [0.2, 0.1, 0.05, 0.02, 0.01, 0.005, 0.002] print 'step h\t Euler error\trate\trk2 error\trate' for h in hlist: (EulerErr, EulerP) = test(eulerstep, h) (RK2Err, RK2P) = test(rk2step, h) print '%.3f\t %.1e\t%.2f \t %.1e\t%.2f' %(h, EulerErr, EulerP, RK2Err, RK2P)

7 Homework: Extension: Integrate a a scalar ODE ODE in in python Implement the classical Runge-Kutta 4 method integrate the example scalar ODE and check the convergence order for it!

8 Homework: Extension: Integrate a a scalar ODE ODE in in python Solution: add RK4Step() function and modify main def RK4Step(u,t,dt,rhs): k1 = dt*rhs(u,t) k2 = dt*rhs(u + 0.5*k1, t + 0.5*dt) k3 = dt*rhs(u + 0.5*k2, t + 0.5*dt) k4 = dt*rhs(u + k3, t + dt) up = u + (k1 + 2*k2 + 2*k3 + k4) / 6.0 return up if name == " main ": hlist = [0.2, 0.1, 0.05, 0.02, 0.01, 0.005, 0.002] print 'step h\t Euler error\trate\trk2 error\trate\trk4 error\trate' for h in hlist: (EulerErr, EulerP) = test(eulerstep, h) (RK2Err, RK2P) = test(rk2step, h) (RK4Err, RK4P) = test(rk4step, h) print '%.3f\t %.1e\t%.2f \t %.1e\t%.2f \t%.1e\t\t%.2f' %(h, EulerErr, EulerP, RK2Err, RK2P, RK4Err, RK4P)

9 Homework: Extension: Integrate a a scalar ODE ODE in in python Result: flux$ python toyint-scalar.py h Euler error rate RK2 error rate RK4 error rate e e e e e e e e e e e e e e e e e e e e e What is happening in the RK4 rate for small h?

10 Homework: Extension: Integrate a a scalar ODE ODE in in python Make this work for vector ODEs using numpy arrays. For now just integrate the scalar ODE with an array of different initial conditions. What changes are necessary in the integrators and integration loop to make sure we do not write into the same memory location for different arrays?

11 Homework: Extension: Integrate a a scalar ODE ODE in in python Integrators unchanged: def RK4Step(u,t,dt,rhs): # pass an array() for u => new arrays get created in the operations k1 = dt*rhs(u,t) # below => k_i are allocated in different memory locations k2 = dt*rhs(u + 0.5*k1, t + 0.5*dt) k3 = dt*rhs(u + 0.5*k2, t + 0.5*dt) k4 = dt*rhs(u + k3, t + dt) up = u + (k1 + 2*k2 + 2*k3 + k4) / 6.0 return up def test(method, h): (ti,yi) = toyint(method, h) err = abs(yi[-1] - yex(ti[-1])) (ti2,yi2) = toyint(method, h/2) err2 = abs(yi2[-1] - yex(ti2[-1])) p = np.log2(err / err2) return (np.min(err), np.min(p)) # err and p are arrays now: choose some # reduction operation to obtain a scalar value # e.g. the worst case: minimum

12 Homework: Extension: Integrate a a scalar ODE ODE in in python Solution array is 2D now def toyint(method, dt): t0 = 1.0 tend = 25.0 u = np.array([1.,.5]) # we pass an array in, so we can later integrate PDEs: # here just two different ICs nsteps = int((tend-t0) / dt) # now we determine the number of steps from the stepsize sol = np.zeros((nsteps,len(u))) # 2d array to store the solution vector for all times n=0 t=t0 sol[0] = u while n < nsteps: n+=1 t+=dt u = method(u,t,dt,rhs) sol[n] = u ts=np.linspace(t0,tend,nsteps) return (ts, sol) # store initial data # update solution array

13 Finally some gravity: Solve the TOV equations for a static spherically symmetric polytropic fluid Metric describing the gravitational field of a spherically star Static equilibrium: Φ=Φ(r) Define the mass function m(r) λ = λ(r) via Tolman-Oppenheimer-Volkoff equations for SS equilibrium stars [B&S sec 1.3] and a polytropic equation of state for the fluid polytropic index total mass-energy density Γ=1+1/n rest-mass density internal energy density per unit rest-mass You need to use the equations for m, P and the polytropic EOS

14 Finally some gravity: Solve the TOV equations for a static spherically symmetric polytropic fluid We have chosen geometric units G=c=1 -- why is this advisable? Start integration at the center of the star by specifying a central pressure or density and vanishing mass: m =0 at. P = P c r =0 ρ = ρ 0 + P/(Γ 1) ρ Use the relation thermodynamics to eliminate which follows from the first law of from the ODE system. Need to regularize the ODEs at the origin: singular terms of the form! Use Taylor expansions / l Hospital s rule. Integrate until the surface of the star: physically we would like to go until p=0, but numerically we will have to stop at some small finite pressure. Compute the total mass as M = Use Runge-Kutta 4 (or experiment with other solvers if you like) R 0 4πr 2 ρdr m/r i Once your code is working and gives sensible results, perform a convergence test; check whether the rate agrees with the expected 4th order rate of RK4.

15 Finally some gravity: Solve the TOV equations for a static spherically symmetric polytropic fluid Consider also the Newtonian limit: In gravitational units has units of length Integrate the TOV equations for a simple reference model K = 100,n=1, Γ=1+1/n, ρ c = You should find a solution close to M =1.4M K n/2 Now for the real physics: compute the equilibrium sequence for n=1 polytropes To do that perform many integrations of the TOV equations with initial mass-energy density ρ c [0, 1.3] and find turning point which is the maximum in the mass-energy you can set the polytropic gas constant to K =1 The turning point should be at P ρ, m(r) r and ρ c =0.420 M =0.164 M(ρ c )

Static Spherically-Symmetric Stellar Structure in General Relativity

Static Spherically-Symmetric Stellar Structure in General Relativity Static Spherically-Symmetric Stellar Structure in General Relativity Christian D. Ott TAPIR, California Institute of Technology cott@tapir.caltech.edu July 24, 2013 1 Introduction Neutron stars and, to

More information

Numerical Methods for Initial Value Problems; Harmonic Oscillators

Numerical Methods for Initial Value Problems; Harmonic Oscillators 1 Numerical Methods for Initial Value Problems; Harmonic Oscillators Lab Objective: Implement several basic numerical methods for initial value problems (IVPs), and use them to study harmonic oscillators.

More information

Computer lab exercises: Simple stellar models and the TOV equation

Computer lab exercises: Simple stellar models and the TOV equation Computer lab exercises: Simple stellar models and the TOV equation I. Hawke, S. Husa, B. Szilágyi September 2004, January 2013 Contents 1 Introduction 2 2 Background: the TOV equation 2 3 Code description

More information

Chapter 6 - Ordinary Differential Equations

Chapter 6 - Ordinary Differential Equations Chapter 6 - Ordinary Differential Equations 7.1 Solving Initial-Value Problems In this chapter, we will be interested in the solution of ordinary differential equations. Ordinary differential equations

More information

Ph 22.1 Return of the ODEs: higher-order methods

Ph 22.1 Return of the ODEs: higher-order methods Ph 22.1 Return of the ODEs: higher-order methods -v20130111- Introduction This week we are going to build on the experience that you gathered in the Ph20, and program more advanced (and accurate!) solvers

More information

MTH 452/552 Homework 3

MTH 452/552 Homework 3 MTH 452/552 Homework 3 Do either 1 or 2. 1. (40 points) [Use of ode113 and ode45] This problem can be solved by a modifying the m-files odesample.m and odesampletest.m available from the author s webpage.

More information

Consistency and Convergence

Consistency and Convergence Jim Lambers MAT 77 Fall Semester 010-11 Lecture 0 Notes These notes correspond to Sections 1.3, 1.4 and 1.5 in the text. Consistency and Convergence We have learned that the numerical solution obtained

More information

Numerical Methods for Initial Value Problems; Harmonic Oscillators

Numerical Methods for Initial Value Problems; Harmonic Oscillators Lab 1 Numerical Methods for Initial Value Problems; Harmonic Oscillators Lab Objective: Implement several basic numerical methods for initial value problems (IVPs), and use them to study harmonic oscillators.

More information

General Relativity and Compact Objects Neutron Stars and Black Holes

General Relativity and Compact Objects Neutron Stars and Black Holes 1 General Relativity and Compact Objects Neutron Stars and Black Holes We confine attention to spherically symmetric configurations. The metric for the static case can generally be written ds 2 = e λ(r)

More information

Here we consider soliton solutions of the Korteweg-de Vries (KdV) equation. This equation is given by u t + u u x + 3 u

Here we consider soliton solutions of the Korteweg-de Vries (KdV) equation. This equation is given by u t + u u x + 3 u Lab 3 Solitons Lab Objective: We study traveling wave solutions of the Korteweg-de Vries (KdV) equation, using a pseudospectral discretization in space and a Runge-Kutta integration scheme in time. Here

More information

The Definition of Density in General Relativity

The Definition of Density in General Relativity The Definition of Density in General Relativity Ernst Fischer Auf der Hoehe 82, D-52223 Stolberg, Germany e.fischer.stolberg@t-online.de August 14, 2014 1 Abstract According to general relativity the geometry

More information

INTRODUCTION TO COMPUTER METHODS FOR O.D.E.

INTRODUCTION TO COMPUTER METHODS FOR O.D.E. INTRODUCTION TO COMPUTER METHODS FOR O.D.E. 0. Introduction. The goal of this handout is to introduce some of the ideas behind the basic computer algorithms to approximate solutions to differential equations.

More information

Physics 584 Computational Methods

Physics 584 Computational Methods Physics 584 Computational Methods Introduction to Matlab and Numerical Solutions to Ordinary Differential Equations Ryan Ogliore April 18 th, 2016 Lecture Outline Introduction to Matlab Numerical Solutions

More information

Polytropic Stars. c 2

Polytropic Stars. c 2 PH217: Aug-Dec 23 1 Polytropic Stars Stars are self gravitating globes of gas in kept in hyostatic equilibrium by internal pressure support. The hyostatic equilibrium condition, as mentioned earlier, is:

More information

Multistep Methods for IVPs. t 0 < t < T

Multistep Methods for IVPs. t 0 < t < T Multistep Methods for IVPs We are still considering the IVP dy dt = f(t,y) t 0 < t < T y(t 0 ) = y 0 So far we have looked at Euler s method, which was a first order method and Runge Kutta (RK) methods

More information

Section 7.4 Runge-Kutta Methods

Section 7.4 Runge-Kutta Methods Section 7.4 Runge-Kutta Methods Key terms: Taylor methods Taylor series Runge-Kutta; methods linear combinations of function values at intermediate points Alternatives to second order Taylor methods Fourth

More information

Numerical solution of ODEs

Numerical solution of ODEs Numerical solution of ODEs Arne Morten Kvarving Department of Mathematical Sciences Norwegian University of Science and Technology November 5 2007 Problem and solution strategy We want to find an approximation

More information

Ordinary Differential Equations

Ordinary Differential Equations CHAPTER 8 Ordinary Differential Equations 8.1. Introduction My section 8.1 will cover the material in sections 8.1 and 8.2 in the book. Read the book sections on your own. I don t like the order of things

More information

Hot White Dwarf Stars

Hot White Dwarf Stars Bakytzhan A. Zhami K.A. Boshkayev, J.A. Rueda, R. Ruffini Al-Farabi Kazakh National University Faculty of Physics and Technology, Almaty, Kazakhstan Supernovae, Hypernovae and Binary Driven Hypernovae

More information

FACULTY OF MATHEMATICAL, PHYSICAL AND NATURAL SCIENCES. AUTHOR Francesco Torsello SUPERVISOR Prof. Valeria Ferrari

FACULTY OF MATHEMATICAL, PHYSICAL AND NATURAL SCIENCES. AUTHOR Francesco Torsello SUPERVISOR Prof. Valeria Ferrari FACULTY OF MATHEMATICAL, PHYSICAL AND NATURAL SCIENCES AUTHOR Francesco SUPERVISOR Prof. Valeria Ferrari Internal structure of a neutron star M [ 1, 2] M n + p + e + µ 0.3km; atomic nuclei +e 0.5km; PRM

More information

Euler s Method, cont d

Euler s Method, cont d Jim Lambers MAT 461/561 Spring Semester 009-10 Lecture 3 Notes These notes correspond to Sections 5. and 5.4 in the text. Euler s Method, cont d We conclude our discussion of Euler s method with an example

More information

FORTRAN 77 Lesson 7. Reese Haywood Ayan Paul

FORTRAN 77 Lesson 7. Reese Haywood Ayan Paul FORTRAN 77 Lesson 7 Reese Haywood Ayan Paul 1 Numerical Integration A general all purpose Numerical Integration technique is the Trapezoidal Method. For most functions, this method is fast and accurate.

More information

Scientific Computing with Case Studies SIAM Press, Lecture Notes for Unit V Solution of

Scientific Computing with Case Studies SIAM Press, Lecture Notes for Unit V Solution of Scientific Computing with Case Studies SIAM Press, 2009 http://www.cs.umd.edu/users/oleary/sccswebpage Lecture Notes for Unit V Solution of Differential Equations Part 1 Dianne P. O Leary c 2008 1 The

More information

Graded Project #1. Part 1. Explicit Runge Kutta methods. Goals Differential Equations FMN130 Gustaf Söderlind and Carmen Arévalo

Graded Project #1. Part 1. Explicit Runge Kutta methods. Goals Differential Equations FMN130 Gustaf Söderlind and Carmen Arévalo 2008-11-07 Graded Project #1 Differential Equations FMN130 Gustaf Söderlind and Carmen Arévalo This homework is due to be handed in on Wednesday 12 November 2008 before 13:00 in the post box of the numerical

More information

Numerical Methods for the Solution of Differential Equations

Numerical Methods for the Solution of Differential Equations Numerical Methods for the Solution of Differential Equations Markus Grasmair Vienna, winter term 2011 2012 Analytical Solutions of Ordinary Differential Equations 1. Find the general solution of the differential

More information

Runge - Kutta Methods for first order models

Runge - Kutta Methods for first order models Runge - Kutta Methods for first order models James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 30, 2013 Outline 1 Runge - Kutte Methods

More information

Lab 1: Iterative Methods for Solving Linear Systems

Lab 1: Iterative Methods for Solving Linear Systems Lab 1: Iterative Methods for Solving Linear Systems January 22, 2017 Introduction Many real world applications require the solution to very large and sparse linear systems where direct methods such as

More information

Lecture 2. Relativistic Stars. Jolien Creighton. University of Wisconsin Milwaukee. July 16, 2012

Lecture 2. Relativistic Stars. Jolien Creighton. University of Wisconsin Milwaukee. July 16, 2012 Lecture 2 Relativistic Stars Jolien Creighton University of Wisconsin Milwaukee July 16, 2012 Equation of state of cold degenerate matter Non-relativistic degeneracy Relativistic degeneracy Chandrasekhar

More information

The Shooting Method for Boundary Value Problems

The Shooting Method for Boundary Value Problems 1 The Shooting Method for Boundary Value Problems Consider a boundary value problem of the form y = f(x, y, y ), a x b, y(a) = α, y(b) = β. (1.1) One natural way to approach this problem is to study the

More information

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0 Math 2250 Lab 4 Name/Unid: 1. (25 points) A man bails out of an airplane at the altitute of 12,000 ft, falls freely for 20 s, then opens his parachute. Assuming linear air resistance ρv ft/s 2, taking

More information

Astronomy 8824: Numerical Methods Notes 2 Ordinary Differential Equations

Astronomy 8824: Numerical Methods Notes 2 Ordinary Differential Equations Astronomy 8824: Numerical Methods Notes 2 Ordinary Differential Equations Reading: Numerical Recipes, chapter on Integration of Ordinary Differential Equations (which is ch. 15, 16, or 17 depending on

More information

Higher Order Taylor Methods

Higher Order Taylor Methods Higher Order Taylor Methods Marcelo Julio Alvisio & Lisa Marie Danz May 6, 2007 Introduction Differential equations are one of the building blocks in science or engineering. Scientists aim to obtain numerical

More information

Numerical methods for solving ODEs

Numerical methods for solving ODEs Chapter 2 Numerical methods for solving ODEs We will study two methods for finding approximate solutions of ODEs. Such methods may be used for (at least) two reasons the ODE does not have an exact solution

More information

Review Higher Order methods Multistep methods Summary HIGHER ORDER METHODS. P.V. Johnson. School of Mathematics. Semester

Review Higher Order methods Multistep methods Summary HIGHER ORDER METHODS. P.V. Johnson. School of Mathematics. Semester HIGHER ORDER METHODS School of Mathematics Semester 1 2008 OUTLINE 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY OUTLINE 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY OUTLINE

More information

Neutron Stars in the Braneworld

Neutron Stars in the Braneworld Neutron Stars in the Braneworld Mike Georg Bernhardt Ruprecht-Karls-Universität Heidelberg Zentrum für Astronomie, Landessternwarte 24 April 29 Outline Introduction Why bother with Extra Dimensions? Braneworlds

More information

Compact Stars in the Braneworld

Compact Stars in the Braneworld Compact Stars in the Braneworld Mike Georg Bernhardt Zentrum für Astronomie Heidelberg Landessternwarte 28 January 29 Outline Review: Relativistic Stars TOV equations Solutions of the TOV equations Neutron

More information

Runge - Kutta Methods for first order models

Runge - Kutta Methods for first order models Runge - Kutta Methods for first order models James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 30, 2013 Outline Runge - Kutte Methods

More information

ESCI 386 Scientific Programming, Analysis and Visualization with Python. Lesson 18 - Linear Algebra

ESCI 386 Scientific Programming, Analysis and Visualization with Python. Lesson 18 - Linear Algebra ESCI 386 Scientific Programming, Analysis and Visualization with Python Lesson 18 - Linear Algebra 1 Matrix Operations In many instances, numpy arrays can be thought of as matrices. In the next slides

More information

Simple ODE Solvers - Derivation

Simple ODE Solvers - Derivation Simple ODE Solvers - Derivation These notes provide derivations of some simple algorithms for generating, numerically, approximate solutions to the initial value problem y (t =f ( t, y(t y(t 0 =y 0 Here

More information

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0 Math 2250 Lab 4 Name/Unid: 1. (35 points) Leslie Leroy Irvin bails out of an airplane at the altitude of 16,000 ft, falls freely for 20 s, then opens his parachute. Assuming linear air resistance ρv ft/s

More information

Tolman Oppenheimer Volkoff (TOV) Stars

Tolman Oppenheimer Volkoff (TOV) Stars Tolman Oppenheimer Volkoff TOV) Stars Aaron Smith 1, 1 Department of Astronomy, The University of Texas at Austin, Austin, TX 78712 Dated: December 4, 2012) We present a set of lecture notes for modeling

More information

Math Numerical Analysis Homework #4 Due End of term. y = 2y t 3y2 t 3, 1 t 2, y(1) = 1. n=(b-a)/h+1; % the number of steps we need to take

Math Numerical Analysis Homework #4 Due End of term. y = 2y t 3y2 t 3, 1 t 2, y(1) = 1. n=(b-a)/h+1; % the number of steps we need to take Math 32 - Numerical Analysis Homework #4 Due End of term Note: In the following y i is approximation of y(t i ) and f i is f(t i,y i ).. Consider the initial value problem, y = 2y t 3y2 t 3, t 2, y() =.

More information

Initial value problems for ordinary differential equations

Initial value problems for ordinary differential equations AMSC/CMSC 660 Scientific Computing I Fall 2008 UNIT 5: Numerical Solution of Ordinary Differential Equations Part 1 Dianne P. O Leary c 2008 The Plan Initial value problems (ivps) for ordinary differential

More information

2nd Year Computational Physics Week 4 (standard): Ordinary differential equations

2nd Year Computational Physics Week 4 (standard): Ordinary differential equations 2nd Year Computational Physics Week 4 (standard): Ordinary differential equations Last compiled September 28, 2017 1 Contents 1 Introduction 4 2 Prelab Questions 4 3 Simple Differential Equations 5 3.1

More information

Differential Equations FMNN10 Graded Project #1 c G Söderlind 2017

Differential Equations FMNN10 Graded Project #1 c G Söderlind 2017 Differential Equations FMNN10 Graded Project #1 c G Söderlind 2017 Published 2017-10-30. Instruction in computer lab 2017-11-02/08/09. Project report due date: Monday 2017-11-13 at 10:00. Goals. The goal

More information

8.1 Introduction. Consider the initial value problem (IVP):

8.1 Introduction. Consider the initial value problem (IVP): 8.1 Introduction Consider the initial value problem (IVP): y dy dt = f(t, y), y(t 0)=y 0, t 0 t T. Geometrically: solutions are a one parameter family of curves y = y(t) in(t, y)-plane. Assume solution

More information

Worksheet 8 Sample Solutions

Worksheet 8 Sample Solutions Technische Universität München WS 2016/17 Lehrstuhl für Informatik V Scientific Computing Univ.-Prof. Dr. M. Bader 19.12.2016/21.12.2016 M.Sc. S. Seckler, M.Sc. D. Jarema Worksheet 8 Sample Solutions Ordinary

More information

Euler s Method, Taylor Series Method, Runge Kutta Methods, Multi-Step Methods and Stability.

Euler s Method, Taylor Series Method, Runge Kutta Methods, Multi-Step Methods and Stability. Euler s Method, Taylor Series Method, Runge Kutta Methods, Multi-Step Methods and Stability. REVIEW: We start with the differential equation dy(t) dt = f (t, y(t)) (1.1) y(0) = y 0 This equation can be

More information

Fourth Order RK-Method

Fourth Order RK-Method Fourth Order RK-Method The most commonly used method is Runge-Kutta fourth order method. The fourth order RK-method is y i+1 = y i + 1 6 (k 1 + 2k 2 + 2k 3 + k 4 ), Ordinary Differential Equations (ODE)

More information

Solving Ordinary Differential equations

Solving Ordinary Differential equations Solving Ordinary Differential equations Taylor methods can be used to build explicit methods with higher order of convergence than Euler s method. The main difficult of these methods is the computation

More information

Ordinary Differential Equations

Ordinary Differential Equations Chapter 7 Ordinary Differential Equations Differential equations are an extremely important tool in various science and engineering disciplines. Laws of nature are most often expressed as different equations.

More information

Chapter 9b: Numerical Methods for Calculus and Differential Equations. Initial-Value Problems Euler Method Time-Step Independence MATLAB ODE Solvers

Chapter 9b: Numerical Methods for Calculus and Differential Equations. Initial-Value Problems Euler Method Time-Step Independence MATLAB ODE Solvers Chapter 9b: Numerical Methods for Calculus and Differential Equations Initial-Value Problems Euler Method Time-Step Independence MATLAB ODE Solvers Acceleration Initial-Value Problems Consider a skydiver

More information

Solution Manual for: Numerical Computing with MATLAB by Cleve B. Moler

Solution Manual for: Numerical Computing with MATLAB by Cleve B. Moler Solution Manual for: Numerical Computing with MATLAB by Cleve B. Moler John L. Weatherwax July 5, 007 Chapter 7 (Ordinary Differential Equations) Problem 7.1 Defining the vector y as y Then we have for

More information

Ordinary Differential Equations II

Ordinary Differential Equations II Ordinary Differential Equations II CS 205A: Mathematical Methods for Robotics, Vision, and Graphics Justin Solomon CS 205A: Mathematical Methods Ordinary Differential Equations II 1 / 29 Almost Done! No

More information

NUMERICAL ANALYSIS 2 - FINAL EXAM Summer Term 2006 Matrikelnummer:

NUMERICAL ANALYSIS 2 - FINAL EXAM Summer Term 2006 Matrikelnummer: Prof. Dr. O. Junge, T. März Scientific Computing - M3 Center for Mathematical Sciences Munich University of Technology Name: NUMERICAL ANALYSIS 2 - FINAL EXAM Summer Term 2006 Matrikelnummer: I agree to

More information

Ordinary Differential Equations (ODEs)

Ordinary Differential Equations (ODEs) Ordinary Differential Equations (ODEs) 1 Computer Simulations Why is computation becoming so important in physics? One reason is that most of our analytical tools such as differential calculus are best

More information

I. Numerical Computing

I. Numerical Computing I. Numerical Computing A. Lectures 1-3: Foundations of Numerical Computing Lecture 1 Intro to numerical computing Understand difference and pros/cons of analytical versus numerical solutions Lecture 2

More information

STATISTICAL THINKING IN PYTHON I. Introduction to summary statistics: The sample mean and median

STATISTICAL THINKING IN PYTHON I. Introduction to summary statistics: The sample mean and median STATISTICAL THINKING IN PYTHON I Introduction to summary statistics: The sample mean and median 2008 US swing state election results Data retrieved from Data.gov (https://www.data.gov/) 2008 US swing state

More information

PH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Abstract

PH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Abstract PH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) IMPACS, Aberystwyth University January 31, 2014 Abstract A set of three coupled ordinary

More information

Do not turn over until you are told to do so by the Invigilator.

Do not turn over until you are told to do so by the Invigilator. UNIVERSITY OF EAST ANGLIA School of Mathematics Main Series UG Examination 216 17 INTRODUCTION TO NUMERICAL ANALYSIS MTHE612B Time allowed: 3 Hours Attempt QUESTIONS 1 and 2, and THREE other questions.

More information

Lecture 10: Linear Multistep Methods (LMMs)

Lecture 10: Linear Multistep Methods (LMMs) Lecture 10: Linear Multistep Methods (LMMs) 2nd-order Adams-Bashforth Method The approximation for the 2nd-order Adams-Bashforth method is given by equation (10.10) in the lecture note for week 10, as

More information

Ordinary Differential Equations

Ordinary Differential Equations Ordinary Differential Equations Introduction: first order ODE We are given a function f(t,y) which describes a direction field in the (t,y) plane an initial point (t 0,y 0 ) We want to find a function

More information

Cooling of Neutron Stars. Dany Page Instituto de Astronomía Universidad Nacional Autónoma de México

Cooling of Neutron Stars. Dany Page Instituto de Astronomía Universidad Nacional Autónoma de México Cooling of Neutron Stars Dany Page Instituto de Astronomía Universidad Nacional Autónoma de México 1 NSCool web site http://www.astroscu.unam.mx/neutrones/nscool/ Dany Page Cooling of Neutron Stars CompStar

More information

Section 2.1 Differential Equation and Solutions

Section 2.1 Differential Equation and Solutions Section 2.1 Differential Equation and Solutions Key Terms: Ordinary Differential Equation (ODE) Independent Variable Order of a DE Partial Differential Equation (PDE) Normal Form Solution General Solution

More information

Solving PDEs with PGI CUDA Fortran Part 4: Initial value problems for ordinary differential equations

Solving PDEs with PGI CUDA Fortran Part 4: Initial value problems for ordinary differential equations Solving PDEs with PGI CUDA Fortran Part 4: Initial value problems for ordinary differential equations Outline ODEs and initial conditions. Explicit and implicit Euler methods. Runge-Kutta methods. Multistep

More information

A First Course on Kinetics and Reaction Engineering Supplemental Unit S5. Solving Initial Value Differential Equations

A First Course on Kinetics and Reaction Engineering Supplemental Unit S5. Solving Initial Value Differential Equations Supplemental Unit S5. Solving Initial Value Differential Equations Defining the Problem This supplemental unit describes how to solve a set of initial value ordinary differential equations (ODEs) numerically.

More information

Variable Step Size Differential Equation Solvers

Variable Step Size Differential Equation Solvers Math55: Differential Equations 1/30 Variable Step Size Differential Equation Solvers Jason Brewer and George Little Introduction The purpose of developing numerical methods is to approximate the solution

More information

Outline Calculus for the Life Sciences II. Pollution in a Lake 1. Introduction. Lecture Notes Numerical Methods for Differential Equations

Outline Calculus for the Life Sciences II. Pollution in a Lake 1. Introduction. Lecture Notes Numerical Methods for Differential Equations Improved Improved Outline Calculus for the Life Sciences II tial Equations Joseph M. Mahaffy, mahaffy@math.sdsu.edu Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences

More information

CHAPTER 5: Linear Multistep Methods

CHAPTER 5: Linear Multistep Methods CHAPTER 5: Linear Multistep Methods Multistep: use information from many steps Higher order possible with fewer function evaluations than with RK. Convenient error estimates. Changing stepsize or order

More information

Universal Relations for the Moment of Inertia in Relativistic Stars

Universal Relations for the Moment of Inertia in Relativistic Stars Universal Relations for the Moment of Inertia in Relativistic Stars Cosima Breu Goethe Universität Frankfurt am Main Astro Coffee Motivation Crab-nebula (de.wikipedia.org/wiki/krebsnebel) neutron stars

More information

X i t react. ~min i max i. R ij smallest. X j. Physical processes by characteristic timescale. largest. t diff ~ L2 D. t sound. ~ L a. t flow.

X i t react. ~min i max i. R ij smallest. X j. Physical processes by characteristic timescale. largest. t diff ~ L2 D. t sound. ~ L a. t flow. Physical processes by characteristic timescale Diffusive timescale t diff ~ L2 D largest Sound crossing timescale t sound ~ L a Flow timescale t flow ~ L u Free fall timescale Cooling timescale Reaction

More information

NUMERICAL SOLUTION OF ODE IVPs. Overview

NUMERICAL SOLUTION OF ODE IVPs. Overview NUMERICAL SOLUTION OF ODE IVPs 1 Quick review of direction fields Overview 2 A reminder about and 3 Important test: Is the ODE initial value problem? 4 Fundamental concepts: Euler s Method 5 Fundamental

More information

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP In this laboratory session we will learn how to. Use MATLAB solvers for solving scalar IVP 2. Use MATLAB solvers for solving higher order ODEs and

More information

Scientific Computing II

Scientific Computing II Scientific Computing II Molecular Dynamics Numerics Michael Bader SCCS Technical University of Munich Summer 018 Recall: Molecular Dynamics System of ODEs resulting force acting on a molecule: F i = j

More information

arxiv: v1 [gr-qc] 6 Dec 2017

arxiv: v1 [gr-qc] 6 Dec 2017 Relativistic polytropic spheres with electric charge: Compact stars, compactness and mass bounds, and quasiblack hole configurations José D. V. Arbañil Departamento de Ciencias, Universidad Privada del

More information

First-Order Differential Equations

First-Order Differential Equations CHAPTER 1 First-Order Differential Equations 1. Diff Eqns and Math Models Know what it means for a function to be a solution to a differential equation. In order to figure out if y = y(x) is a solution

More information

[ ] is a vector of size p.

[ ] is a vector of size p. Lecture 11 Copyright by Hongyun Wang, UCSC Recap: General form of explicit Runger-Kutta methods for solving y = F( y, t) k i = hfy n + i1 j =1 c ij k j, t n + d i h, i = 1,, p + p j =1 b j k j A Runge-Kutta

More information

Lecture 17: Ordinary Differential Equation II. First Order (continued)

Lecture 17: Ordinary Differential Equation II. First Order (continued) Lecture 17: Ordinary Differential Equation II. First Order (continued) 1. Key points Maple commands dsolve dsolve[interactive] dsolve(numeric) 2. Linear first order ODE: y' = q(x) - p(x) y In general,

More information

Here we consider soliton solutions of the Korteweg-de Vries (KdV) equation. This equation is given by

Here we consider soliton solutions of the Korteweg-de Vries (KdV) equation. This equation is given by 17 Solitons Lab Objective: We study traveling wave solutions of the Korteweg-de Vries (KdV) equation, using a pseudospectral discretization in space and a Runge-Kutta integration scheme in time. Here we

More information

Ordinary Differential Equations II: Runge-Kutta and Advanced Methods

Ordinary Differential Equations II: Runge-Kutta and Advanced Methods Ordinary Differential Equations II: Runge-Kutta and Advanced Methods Sam Sinayoko Numerical Methods 3 Contents 1 Learning Outcomes 2 2 Introduction 2 2.1 Note................................ 4 2.2 Limitations

More information

Calculus for the Life Sciences

Calculus for the Life Sciences Improved Calculus for the Life Sciences ntial Equations Joseph M. Mahaffy, jmahaffy@mail.sdsu.edu Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences Research Center

More information

A Brief Introduction to Numerical Methods for Differential Equations

A Brief Introduction to Numerical Methods for Differential Equations A Brief Introduction to Numerical Methods for Differential Equations January 10, 2011 This tutorial introduces some basic numerical computation techniques that are useful for the simulation and analysis

More information

Runge - Kutta Methods for first and second order models

Runge - Kutta Methods for first and second order models Runge - Kutta Methods for first and second order models James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 3, 2013 Outline 1 Runge -

More information

You may not use your books, notes; calculators are highly recommended.

You may not use your books, notes; calculators are highly recommended. Math 301 Winter 2013-14 Midterm 1 02/06/2014 Time Limit: 60 Minutes Name (Print): Instructor This exam contains 8 pages (including this cover page) and 6 problems. Check to see if any pages are missing.

More information

Runge-Kutta and Collocation Methods Florian Landis

Runge-Kutta and Collocation Methods Florian Landis Runge-Kutta and Collocation Methods Florian Landis Geometrical Numetric Integration p.1 Overview Define Runge-Kutta methods. Introduce collocation methods. Identify collocation methods as Runge-Kutta methods.

More information

Modeling and Experimentation: Compound Pendulum

Modeling and Experimentation: Compound Pendulum Modeling and Experimentation: Compound Pendulum Prof. R.G. Longoria Department of Mechanical Engineering The University of Texas at Austin Fall 2014 Overview This lab focuses on developing a mathematical

More information

Section 7.2 Euler s Method

Section 7.2 Euler s Method Section 7.2 Euler s Method Key terms Scalar first order IVP (one step method) Euler s Method Derivation Error analysis Computational procedure Difference equation Slope field or Direction field Error Euler's

More information

Differential Equations

Differential Equations Pysics-based simulation xi Differential Equations xi+1 xi xi+1 xi + x x Pysics-based simulation xi Wat is a differential equation? Differential equations describe te relation between an unknown function

More information

Conjugate-Gradient. Learn about the Conjugate-Gradient Algorithm and its Uses. Descent Algorithms and the Conjugate-Gradient Method. Qx = b.

Conjugate-Gradient. Learn about the Conjugate-Gradient Algorithm and its Uses. Descent Algorithms and the Conjugate-Gradient Method. Qx = b. Lab 1 Conjugate-Gradient Lab Objective: Learn about the Conjugate-Gradient Algorithm and its Uses Descent Algorithms and the Conjugate-Gradient Method There are many possibilities for solving a linear

More information

Multistage Methods I: Runge-Kutta Methods

Multistage Methods I: Runge-Kutta Methods Multistage Methods I: Runge-Kutta Methods Varun Shankar January, 0 Introduction Previously, we saw that explicit multistep methods (AB methods) have shrinking stability regions as their orders are increased.

More information

Stability Results in the Theory of Relativistic Stars

Stability Results in the Theory of Relativistic Stars Stability Results in the Theory of Relativistic Stars Asad Lodhia September 5, 2011 Abstract In this article, we discuss, at an accessible level, the relativistic theory of stars. We overview the history

More information

Runge-Kutta methods. With orders of Taylor methods yet without derivatives of f (t, y(t))

Runge-Kutta methods. With orders of Taylor methods yet without derivatives of f (t, y(t)) Runge-Kutta metods Wit orders of Taylor metods yet witout derivatives of f (t, y(t)) First order Taylor expansion in two variables Teorem: Suppose tat f (t, y) and all its partial derivatives are continuous

More information

Numerical Integration of Ordinary Differential Equations for Initial Value Problems

Numerical Integration of Ordinary Differential Equations for Initial Value Problems Numerical Integration of Ordinary Differential Equations for Initial Value Problems Gerald Recktenwald Portland State University Department of Mechanical Engineering gerry@me.pdx.edu These slides are a

More information

Ordinary Differential Equations II

Ordinary Differential Equations II Ordinary Differential Equations II CS 205A: Mathematical Methods for Robotics, Vision, and Graphics Justin Solomon CS 205A: Mathematical Methods Ordinary Differential Equations II 1 / 33 Almost Done! Last

More information

Chapter 7 Neutron Stars

Chapter 7 Neutron Stars Chapter 7 Neutron Stars 7.1 White dwarfs We consider an old star, below the mass necessary for a supernova, that exhausts its fuel and begins to cool and contract. At a sufficiently low temperature the

More information

We begin exploring Euler s method by looking at direction fields. Consider the direction field below.

We begin exploring Euler s method by looking at direction fields. Consider the direction field below. Emma Reid- MA 66, Lesson 9 (SU 17) Euler s Method (.7) So far in this course, we have seen some very special types of first order ODEs. We ve seen methods to solve linear, separable, homogeneous, Bernoulli,

More information

Numerical Differential Equations: IVP

Numerical Differential Equations: IVP Chapter 11 Numerical Differential Equations: IVP **** 4/16/13 EC (Incomplete) 11.1 Initial Value Problem for Ordinary Differential Equations We consider the problem of numerically solving a differential

More information

Finite Differences for Differential Equations 28 PART II. Finite Difference Methods for Differential Equations

Finite Differences for Differential Equations 28 PART II. Finite Difference Methods for Differential Equations Finite Differences for Differential Equations 28 PART II Finite Difference Methods for Differential Equations Finite Differences for Differential Equations 29 BOUNDARY VALUE PROBLEMS (I) Solving a TWO

More information

Mass-Radius Relation: Hydrogen Burning Stars

Mass-Radius Relation: Hydrogen Burning Stars Mass-Radius Relation: Hydrogen Burning Stars Alexis Vizzerra, Samantha Andrews, and Sean Cunningham University of Arizona, Tucson AZ 85721, USA Abstract. The purpose if this work is to show the mass-radius

More information

Lecture 42 Determining Internal Node Values

Lecture 42 Determining Internal Node Values Lecture 42 Determining Internal Node Values As seen in the previous section, a finite element solution of a boundary value problem boils down to finding the best values of the constants {C j } n, which

More information