Ordinary Differential Equations

Similar documents
Lecture IV: Time Discretization

Lecture V: The game-engine loop & Time Integration

CHAPTER 1 INTRODUCTION TO NUMERICAL METHOD

Introduction to First Order Equations Sections

a = v2 R where R is the curvature radius and v is the car s speed. To provide this acceleration, the car needs static friction force f = ma = mv2

Consistency and Convergence

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

Newton s Laws.

Ordinary differential equations. Phys 420/580 Lecture 8

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Physics 8.01 Physics Fall Term = # v x. t " =0. are the values at t = 0.

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

Problem Set 4 Momentum and Continuous Mass Flow Solutions

Lecture 1 Notes: 06 / 27. The first part of this class will primarily cover oscillating systems (harmonic oscillators and waves).

Differential Equations

AIMS Exercise Set # 1

Solutions to the Review Questions

Chap. 20: Initial-Value Problems

Simple Harmonic Motion

Energy, Work & Power Questions

2.2 Average vs. Instantaneous Description

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Mechanics. Time (s) Distance (m) Velocity (m/s) Acceleration (m/s 2 ) = + displacement/time.

HSC PHYSICS ONLINE B F BA. repulsion between two negatively charged objects. attraction between a negative charge and a positive charge

Lecture 14: Ordinary Differential Equation I. First Order

Technical aspects of road time trialing

Ordinary Differential Equations II

There are two main types of friction:

Lecture for Week 6 (Secs ) Derivative Miscellany I

Mechanics. Flight Lessons 1: Basic Flight. Position, starting with 2 dimensions

2. Kinetic friction - The force that acts against an object s motion. - Occurs once static friction has been overcome and object is moving

Simple Harmonic Motion Concept Questions

Inclined Planes Worksheet Answers

TP 1: Euler s Algorithm-Air Resistance-Introduction to Fortran

CEE 271: Applied Mechanics II, Dynamics Lecture 9: Ch.13, Sec.4-5

Forces Part 1: Newton s Laws

4.2. Visualize: Assess: Note that the climber does not touch the sides of the crevasse so there are no forces from the crevasse walls.

Physics 114A Introduction to Mechanics (without calculus)

CHAPTER 6: IN AN ISOLATED SYSTEM, ENERGY IS TRANSFERRED FROM ONE OBJECT TO ANOTHER WHENEVER WORK IS DONE

FRICTIONAL FORCES. Direction of frictional forces... (not always obvious)... CHAPTER 5 APPLICATIONS OF NEWTON S LAWS

Class 11 Physics NCERT Exemplar Solutions Motion in a Straight Line

Physics 20 Homework 2 SIMS 2016

Mechanics & Properties of Matter 5: Energy and Power

Maths III - Numerical Methods

NUMERICAL SOLUTION OF ODE IVPs. Overview

Physics 1A, Summer 2011, Summer Session 1 Quiz 3, Version A 1

Displacement, Velocity, and Acceleration AP style

Chapter 2 Motion Along A Straight Line

Notation Nodes are data points at which functional values are available or at which you wish to compute functional values At the nodes fx i

Numerical Methods. King Saud University

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

EQUATIONS OF MOTION: NORMAL AND TANGENTIAL COORDINATES

ODE Runge-Kutta methods

Euler s Method, cont d

Exam Question 6/8 (HL/OL): Circular and Simple Harmonic Motion. February 1, Applied Mathematics: Lecture 7. Brendan Williamson.

AM205: Assignment 3 (due 5 PM, October 20)

Chapter: Newton s Laws of Motion

Chapter 3 Acceleration

Chapter 3 Acceleration

CEE 271: Applied Mechanics II, Dynamics Lecture 1: Ch.12, Sec.1-3h

Predicting the future with Newton s Second Law

WS-CH-4 Motion and Force Show all your work and equations used. Isaac Newton ( )

FINITE DIFFERENCES. Lecture 1: (a) Operators (b) Forward Differences and their calculations. (c) Backward Differences and their calculations.

Lecture Notes for PHY 405 Classical Mechanics

Physics 2A Chapter 4: Forces and Newton s Laws of Motion

ENGI 3424 First Order ODEs Page 1-01

Chapter 6. Circular Motion and Other Applications of Newton s Laws

Math221: HW# 2 solutions

Chapter 6 Work and Kinetic Energy

Lecture 6.1 Work and Energy During previous lectures we have considered many examples, which can be solved using Newtonian approach, in particular,

PHYSICS 121 FALL Homework #3 - Solutions. Problems from Chapter 5: 3E, 7P, 11E, 15E, 34P, 45P

Numerical Analysis Exam with Solutions

Chapter 3 Acceleration

13.7 Power Applied by a Constant Force

EQUATIONS OF MOTION: NORMAL AND TANGENTIAL COORDINATES (Section 13.5)

Physics 207 Lecture 12. Lecture 12

Computational Techniques Prof. Dr. Niket Kaisare Department of Chemical Engineering Indian Institute of Technology, Madras

Conceptual Questions. SPH4U1 - Dynamics Problems Set 3

Ordinary Differential Equations II

ECE257 Numerical Methods and Scientific Computing. Ordinary Differential Equations

Motion Along a Straight Line

FORCE AND MOTION. Conceptual Questions F G as seen in the figure. n, and a kinetic frictional force due to the rough table surface f k

Differential Equations

Circular Motion Test Review

Chapter 2. Motion in One Dimension. AIT AP Physics C

Physics for Scientists and Engineers. Chapter 6 Dynamics I: Motion Along a Line

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

Calculus Review. v = x t

Numerical Algorithms for ODEs/DAEs (Transient Analysis)

Lecture 4: Numerical solution of ordinary differential equations

AH Mechanics Checklist (Unit 1) AH Mechanics Checklist (Unit 1) Rectilinear Motion

4. As you increase your push, will friction on the crate increase also? Ans. Yes it will.

Homework #5 Solution Due Thursday, December 01, 2011

Chapter 2: Motion along a straight line

What are two forms of Potential Energy that we commonly use? Explain Conservation of Energy and how we utilize it for problem-solving technics.

Mechanics 2. Revision Notes

ENGI 2422 First Order ODEs - Separable Page 3-01

Physics 106a, Caltech 4 December, Lecture 18: Examples on Rigid Body Dynamics. Rotating rectangle. Heavy symmetric top

Astronomy 8824: Numerical Methods Notes 2 Ordinary Differential Equations

Physics 584 Computational Methods

Checking the Radioactive Decay Euler Algorithm

Transcription:

Ordinary Differential Equations In this lecture, we will look at different options for coding simple differential equations. Start by considering bicycle riding as an example. Why does a bicycle move forward? Friction between the wheel and the ground. We will assume no relative motion (no sliding or slipping), so no energy lost there. Sources of energy loss: friction among parts wind resistance gravity (if going uphill) No relative motion Winter Semester 2006/7 Computational Physics I Lecture 4 1

Bicycle Riding Assuming flat terrain and no friction or wind resistance: F is force provided by rider m is mass of bicycle + rider F m = dv dt F is difficult to determine. Easier to work with power. Elite riders can produce a steady 400W for an extended period (1 hour or so). P = de dt E is the (kinetic) energy = 1/2mv 2 P is the power provided by the rider = mv dv/dt Winter Semester 2006/7 Computational Physics I Lecture 4 2

Bicycle Riding We assume P is a constant (not good approximation when first get started, but once moving this is better). P = mvv or dv dt = P mv can write vdv = P m dt integrating yields 1 2 (v2 v 0 2 ) = P m (t t 0 ) setting t 0 = 0, we have v = 2Pt m + v 2 0 Result is clearly nonsense - need friction and wind resistance! Winter Semester 2006/7 Computational Physics I Lecture 4 3

Bicycle Riding Let s see how we can code this. On the computer, we go back to the definition of the derivative as a limit of a ratio of differences: dv dt = lim v(t + t) v(t) v(t + t) v(t) t0 t t where t is the (usually constant) step size used in the computer If we take v(t = 0) = v 0 and use the notation v i = v(it), then v i+1 = v i + f (v,t)t, where f (v,t) = dv dt In our example: V i+1 v i+1 v i + P t v i mv i t i Use slope at ti to estimate v at later time. t i+1 Winter Semester 2006/7 Computational Physics I Lecture 4 4

Bicycle Rider Looking at the previous diagram, probably some thoughts arise: The smaller the time step, the better the approximation (but then the amount of computer time will go up as T/t) Maybe there are better ways to approximate the best slope for the time interval. We will look into this later. Forging ahead with this simple algorithm (Called Euler algorithm): t=1 s t=0.1 s Winter Semester 2006/7 Computational Physics I Lecture 4 5

Bicycle Rider Let s now add some friction and air resistance. At large enough speed, we can approximate the drag force as: F drag Bv 2 We ignore friction in the bike - it is usually a small effect compared to air resistance. The coefficient B can be broken down as follows: B = 1 2 CA where C is the 'drag coefficient' - number not too far from 1 is the density of air A is the effective frontal area Typical bike riding, C=0.9 Winter Semester 2006/7 Computational Physics I Lecture 4 6

Bicycle Rider Let s add this drag force to our equations: F drag = m dv dt, or v = F drag m t Putting this together with out previous expression v = P mv t + F drag t, or, on the computer m v i+1 = v i + P t CAv 2 i mv i 2m t We take the following values: A = 0.33 m 2 C = 0.9 m = 80 kg (racer+bike) =1 kg m 3 Winter Semester 2006/7 Computational Physics I Lecture 4 7

Bicycle Rider We can solve for the equilibrium speed by setting the derivative to zero: 0 = P mv CAv2 2m v 3 = 2P CA v = 13.9 m s = 50 km h Compare to numerical solution with Euler algorithm: Terminal velocity is 50 km/h. This is very close to actual max speeds achieved by professional riders. Winter Semester 2006/7 Computational Physics I Lecture 4 8

Error in Numerical Differentiation To estimate the error from the algorithm to calculate the derivative numerically, we compare to a Taylor series expansion: f (x + h) f (x) h = f (x) + hf (x) + h2 2 h f (x) + f (x) = f (x) + h 2 f (x) + When we replace f (x) f (x + h) f (x) h We make an error of about hf (x) Assuming that h is small so that each term in the series is much smaller than the previous one. Winter Semester 2006/7 Computational Physics I Lecture 4 9

Error in Numerical Differentiation How does this compare with the round-off error of the computer? f x f x f x 3 + f (x) h 2 See Scherer Lecture notes So: want minimum h to minimize algorithm error, but small h can lead to large rounding error (they accumulate). Optimal value when errors comparable: h 2 f (x) = f (x) h 2 Winter Semester 2006/7 Computational Physics I Lecture 4 10

For our bicycle riding example : dv dt = P mv CAv 2 2m d 2 v dt = P 2 mv + CAv 2 m Bicycle Rider Example dv dt = P 2 PCA m 2 3 + C2 2 A 2 v 3 v 2m 2 2m 2 Condition on previous page yields : t 2 = 4 v(t) v (t) 4 v(t) v (t) At small v, want t At large v, can be much larger (Because v 0) t = = 310 4 for single precision, 10 8 double precision Winter Semester 2006/7 Computational Physics I Lecture 4 11

More on Derivatives We now look into different approaches to code derivatives. We use the Mean Value Theorem for guidance: In calculus, the mean value theorem states, roughly, that given a section of a smooth curve, there is a point on that section at which the derivative (slope) of the curve is equal to the "average" derivative of the section. It is used to prove theorems that make global conclusions about a function on an interval starting from local hypotheses about derivatives at points of the interval. (Wikipedia) Derivative at c is same as average derivative from a to b How does this guide us? Winter Semester 2006/7 Computational Physics I Lecture 4 12

Mean Value Theorem Note that replacing dt t is equivalent to integration t 2 x = dx dt dt = x(t 2 ) x(t 1 ) t 1 We can state the Mean Value Theorem as x(t + t) = x(t) + dx dt tm t where t m is between t 1,t 2 Euler Approximation V i+1 In the Euler approximation, t m = t 1 v i t i t i+1 Error d2 x dt 2 Look at some alternative choices Winter Semester 2006/7 Computational Physics I Lecture 4 13

More on Derivatives If we look at what we have done, basically, we estimate the derivative over the interval t with the derivative at the start of the interval. V i+1 v i t i t i+1 We can do better by trying to find an average derivative: V i+1 v i We look at options for finding this average derivative t i t i+1 Winter Semester 2006/7 Computational Physics I Lecture 4 14

Runge-Kutta Method 2 nd order Runge-Kutta construction: x(t + t) = x(t) + f ( x, t )t where dx dt = f (x,t) x = x(t) + 1 2 f (x(t),t)t t = t + 1 2 t so, dx dt tm is approximated by f ( x, t ) where t is at the middle of the time interval, and x is the Euler approximation for x at the midpoint To see the accuracy of a particular method, we compare to a Taylor series expansion: x(t + t) = x(t) + dx dt t + 1 2 d 2 x dt 2 (t)2 + 1 6 d 3 x dt 3 (t)3 + = x (n ) (t) (t) n n! Winter Semester 2006/7 Computational Physics I Lecture 4 15 n = 0

Runge-Kutta Method x(t + t) = x(t) + dx dt t + 1 d 2 x 2 dt 2 (t)2 + 1 d 3 x Taylor Series: 6 dt 3 (t)3 + The Euler Method is of O(t), because that is highest order term 2 nd order R-K: x(t + t) = x(t) + f ( x, t )t = x(t) + dx t t dx = dx + 1 f (x,t) 2 x dt = dt so, x(t + t) = x(t) + dxt + 1 2 f (x,t) t dx dt + 1 f (x,t) 2 x = x(t) + dx dt t + 1 2 Winter Semester 2006/7 Computational Physics I Lecture 4 16 d dtt dx dt t + 1 f (x,t) 2 t d 2 x dt 2 (t)2 O(t) 2 t t

Runge-Kutta Method Let s try it out on the bike riding example: dv dt = f (v,t) = P 2 CAv mv 2m v(t + t) = v(t) + f ( v, t )t v = v(t) + 1 2 f (v,t)t = v(t) + 1 2 P mv CAv 2 2m t t = t + 1 2 t v(t + t) = v(t) + p mv CA v 2 2m t Winter Semester 2006/7 Computational Physics I Lecture 4 17

Runge-Kutta Method For this comparison, we take the same time step in all methods (1s). Exact Euler method 2 nd order Runge-Kutta 4 th order Runge-Kutta Winter Semester 2006/7 Computational Physics I Lecture 4 18

4 th order Runge-Kutta: Runge-Kutta Method x(t + t) = x(t) + 1 [ 6 f ( x 1, t 1 ) + 2 f ( x 2, t 2 ) + 2 f ( x 3, t 3 ) + f ( x 4, t 4 )]t with x 1 = x(t) t 1 = t x 2 = x(t) + 1 2 f (x 1, t 1 )t t 2 = t + 1 2 t x 3 = x(t) + 1 2 f (x 2, t 2 )t t 3 = t + 1 2 t x 4 = x(t) + 1 2 f (x 3, t 3 )t t 4 = t + t Good to (t) 4 Winter Semester 2006/7 Computational Physics I Lecture 4 19

Graphical Representation Euler method Take big time step (2s) to see effect of algorithm clearly 4 th order R-K True curve 2 nd order R-K Winter Semester 2006/7 Computational Physics I Lecture 4 20

dx dt x(t + t 2 ) x(t t 2 ) t x(t + t 2 ) x(t t 2 ) t Centered Difference Method (Verlet) The Euler & R-K methods look forward to try to estimate x at a later t. Can also symmetrize, in that we look forward and backward: = x(t) + Centered Difference Method dx dt t + 1 24 x t 2 + 1 2 t d 3 x dt 3 (t)3 x (t 2 )2 + x(t) t = dx dt + 1 24 d 3 x dt 3 (t)2 x t 2 + 1 2 x(t + t) = x(t t) + 2 f (x,t)t with redefinition of t x (t 2 )2 i.e., good to O(t) 2. Optimal step width from (t)2 24 f (x) = f (x) 2 t Winter Semester 2006/7 Computational Physics I Lecture 4 21

Centered Difference Method Practical issue with this method is - how to get started? To evaluate x 1, need not only x 0 but also x -1. Use Euler method of R- K to get x 1, then can proceed. Exact Euler method 2 nd order Runge-Kutta Centered difference method Winter Semester 2006/7 Computational Physics I Lecture 4 22

Graphical Representation Red arrows show the derivative dv/dt at a particular v. Centered difference unstable because: v i + 2 = v i + 2 dv i +1 dt t If v i > v eq, and v i +1 < v eq then dv i +1 dt > 0 Similarly for v i < v eq Winter Semester 2006/7 Computational Physics I Lecture 4 23

Extrapolation Methods Extrapolation Methods (Romberg): Here, we try to guess the true value of the derivative by taking smaller and smaller step sizes and extrapolating to zero step size. Define D 0 = D(t), D 1 = D t 2,... Fit polynomial p(t) = a + bt + c(t) 2 + to D(t) Estimate D = a Example: extrapolated centered difference method: D i (h) = x(t + h) x(t h) 2h h = t 2 i Winter Semester 2006/7 Computational Physics I Lecture 4 24

Exercises 1. Work out the terminal velocity for a bicyclist when not travelling on flat terrain (assume a 10% slope, which is quite steep), and compare to the Euler and 4 th order Runge-Kutta approaches. Investigate the effect of different step sizes. 2. Steadily diminish the step size in the example of the bicyclist travelling on flat terrain with air resistance until you find no further improvement (compare to the analytic result). Compare your final step size with expression on P.10. Winter Semester 2006/7 Computational Physics I Lecture 4 25