Numerical Methods for the Solution of Differential Equations

Similar documents
ECE257 Numerical Methods and Scientific Computing. Ordinary Differential Equations

MTH 452/552 Homework 3

Fourth Order RK-Method

Chapter 5 Exercises. (a) Determine the best possible Lipschitz constant for this function over 2 u <. u (t) = log(u(t)), u(0) = 2.

COSC 3361 Numerical Analysis I Ordinary Differential Equations (II) - Multistep methods

Applied Math for Engineers

Initial-Value Problems for ODEs. Introduction to Linear Multistep Methods

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

Module 4: Numerical Methods for ODE. Michael Bader. Winter 2007/2008

Numerical Differential Equations: IVP

9.6 Predictor-Corrector Methods

Lecture V: The game-engine loop & Time Integration

Ordinary differential equations - Initial value problems

Lecture IV: Time Discretization

Solving Ordinary Differential Equations

Ordinary Differential Equations II

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

CS 450 Numerical Analysis. Chapter 9: Initial Value Problems for Ordinary Differential Equations

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

CS520: numerical ODEs (Ch.2)

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 9

Ordinary Differential Equations II

Scientific Computing: An Introductory Survey

Numerical Methods - Initial Value Problems for ODEs

multistep methods Last modified: November 28, 2017 Recall that we are interested in the numerical solution of the initial value problem (IVP):

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

Module 6 : Solving Ordinary Differential Equations - Initial Value Problems (ODE-IVPs) Section 1 : Introduction

Mathematics for chemical engineers. Numerical solution of ordinary differential equations

NUMERICAL SOLUTION OF ODE IVPs. Overview

Initial value problems for ordinary differential equations

Lecture 8: Calculus and Differential Equations

Lecture 8: Calculus and Differential Equations

1 Error Analysis for Solving IVP

Numerical Analysis. A Comprehensive Introduction. H. R. Schwarz University of Zürich Switzerland. with a contribution by

Chap. 20: Initial-Value Problems

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

MB4018 Differential equations

Applied Numerical Analysis

Math 128A Spring 2003 Week 12 Solutions

Solving Ordinary Differential equations

Numerical solution of ODEs

Numerical Methods for Engineers. and Scientists. Applications using MATLAB. An Introduction with. Vish- Subramaniam. Third Edition. Amos Gilat.

Bindel, Fall 2011 Intro to Scientific Computing (CS 3220) Week 12: Monday, Apr 18. HW 7 is posted, and will be due in class on 4/25.

Jim Lambers MAT 772 Fall Semester Lecture 21 Notes

5. Ordinary Differential Equations. Indispensable for many technical applications!

Ordinary differential equation II

4.4 Computing π, ln 2 and e

Ordinary Differential Equations

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

(5.5) Multistep Methods

Initial value problems for ordinary differential equations


Multistep Methods for IVPs. t 0 < t < T

Solving scalar IVP s : Runge-Kutta Methods

Consistency and Convergence

Final Exam Sample Problems, Math 246, Spring 2018

5.6 Multistep Methods

Numerical Methods for Initial Value Problems; Harmonic Oscillators

ODE Runge-Kutta methods

Math 128A Spring 2003 Week 11 Solutions Burden & Faires 5.6: 1b, 3b, 7, 9, 12 Burden & Faires 5.7: 1b, 3b, 5 Burden & Faires 5.

Lecture 4: Numerical solution of ordinary differential equations

MATH 350: Introduction to Computational Mathematics

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

Chapter 10. Initial value Ordinary Differential Equations

Differential Equations

Differential Equations

Ordinary Differential Equations

Numerical Integration of Ordinary Differential Equations for Initial Value Problems

Ordinary Differential Equations

2.29 Numerical Fluid Mechanics Fall 2011 Lecture 20

On interval predictor-corrector methods

Ordinary Differential Equations. Monday, October 10, 11

The Initial Value Problem for Ordinary Differential Equations

The family of Runge Kutta methods with two intermediate evaluations is defined by

ENGI9496 Lecture Notes State-Space Equation Generation

Numerical Methods for Differential Equations

Worksheet 8 Sample Solutions

Part IB Numerical Analysis

Computational Methods CMSC/AMSC/MAPL 460. Ordinary differential equations

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

CHAPTER 5: Linear Multistep Methods

Dynamic Systems. Simulation of. with MATLAB and Simulink. Harold Klee. Randal Allen SECOND EDITION. CRC Press. Taylor & Francis Group

Numerical Methods for Initial Value Problems; Harmonic Oscillators

Modeling & Simulation 2018 Lecture 12. Simulations

Vector Fields and Solutions to Ordinary Differential Equations using MATLAB/Octave

Lecture 10: Linear Multistep Methods (LMMs)

Mathematical Models. MATH 365 Ordinary Differential Equations. J. Robert Buchanan. Spring Department of Mathematics

Mathematical Models. MATH 365 Ordinary Differential Equations. J. Robert Buchanan. Fall Department of Mathematics

Solution. It is evaluating the definite integral r 1 + r 4 dr. where you can replace r by any other variable.

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

Euler s Method, cont d

Numerical Methods for Differential Equations

Cyber-Physical Systems Modeling and Simulation of Continuous Systems

Efficient Simulation of Physical System Models Using Inlined Implicit Runge Kutta Algorithms

MATH 100 Introduction to the Profession

Computer lab for MAN460

Name of the Student: Unit I (Solution of Equations and Eigenvalue Problems)

Numerical Methods for ODEs. Lectures for PSU Summer Programs Xiantao Li

u n 2 4 u n 36 u n 1, n 1.

Math 660 Lecture 4: FDM for evolutionary equations: ODE solvers

Transcription:

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 equation ẏ = y 2. In addition, find particular solutions for the initial conditions y(1) = 1, y(1) = 1, and y(1) = 0. 2. Find the general solution of the differential equation (t 2 +1)ẏ +ty = 1 2. 3. Find the general solution of the differential equation (3t y)ẏ +t = 3y. NB: This equation is of homogeneous type. Numerical Solution of ODEs 4. Implement in Matlab or Octave the explicit Euler method, the midpoint method, and Heun s method for the solution of an ODE (or a system of ODEs) of the form up to some given time T > t 0. Test your code on the system of ODEs ẏ(t) = f ( t,y(t) ), y(t 0 ) = y 0, (1) ẏ 1 = y 2, ẏ 2 = y 1, y 1 (0) = 1, y 2 (0) = 0, (2) 1

with final time T = 2π, and compute the approximation error err j (the norm of the difference between the solution of the ODE and its approximation) for step sizes 2π/2 j, j = 1,...,10 (the solution is: y 1 (t) = cos(t), y 2 (t) = sin(t)). A numerical approximation of the order of the methods (the numerical order) can be found by observing the ratios ln(err j+1/err j ) ln(2) for large j. Explain why, and determine the numerical order of the methods. 5. Use your code to solve the ODE ẏ = 3y 2/3, y( 1) = 1, and determine the numerical order of the methods at the final times T = 0.5, T = 0, and T = 1. Explain the result! 6. Implement in Matlab or Octave Taylor s method of second order for the solution of an ODE of the form (1). Test your implementation on the ODE Multi-step Methods ẏ(t) = y(t)cos(t), y(0) = 1. 7. Write a Matlab or Octave implementation of the Adams Bashforth method of third order and test your code on the system of ODEs in (2). 8. Write a Matlab or Octave implementation of a predictor corrector method based on the third order explicit and implicit Adams methods and test your code on the system of ODEs in (2). Stiff ODEs In the next exercises, we will mainly consider the mass spring system discussed in the lecture, which can lead to a stiff ODE depending on the relative size of the input parameters. The second order system of ODEs is given by the equations with initial conditions ÿ 1 = k 1 m 1 y 1 + k 2 m 1 (y 2 y 1 ), ÿ 2 = k 2 m 2 (y 2 y 1 ), y 1 (0) = a, ẏ 1 (0) = b, y 2 (0) = c, ẏ 2 (0) = d. Here, y 1 and y 2 describe the displacement of the masses m 1 and m 2 from the equilibrium position, and k 1 and k 2 the spring constants.

9. Rewrite the second order mass spring system as a first order system by introducing auxiliary variables for ẏ 1 and ẏ 2. 10. Write a Matlab or Octave implementation of the classical Runge Kutta method and use it for computing numerical solutions of the mass spring system with the following parameters: a) Non-stiff setting: b) Stiff setting: k 1 = 100, k 2 = 200, m 1 = 10, m 2 = 5, a = 0, b = 1, c = 0, d = 1. k 1 = 100, k 2 = 2000, m 1 = 10, m 2 = 0.1, a = 0, b = 1, c = 0, d = 1. Solve the systems for different numbers of steps and compare the results (for the stiff setting, the comparison between 1000 and 1005 steps can be interesting). In addition, test your implementation on the linear ODE ẏ = 200 ( y sin(t) ) +cos(t). (3) 11. The implicit Euler method for the solution of a linear ODE of the form is defined by the iteration ẏ = Ay, y(0) = y 0, y k+1 = y k +hay k+1. Write a Matlab or Octave implementation and use it for the numerical solution of the mass spring system in the stiff setting. 12. Write a Matlab or Octave implementation of the trapezoidal rule (second order Adams Moulton method) for linear ODEs and use it for the numerical solution of the mass spring system in the stiff setting. 13. Modify your implementations of the implicit Euler method and the trapezoidal rule in such a way that they can also be used for linear (inhomogeneous and nonautonomous) ODEs of the form ẏ = g(t)+a(t)y, where g: R R d and A: R R d d are given functions. Test your implementations on the ODE (3) and compare the results for different initial conditions y(0) R and different step sizes.

A Non-linear Stiff ODE Next we consider the non-linear system of ODEs with initial conditions mÿ 1 = k ( y l ) y 1 y d y,ẏ y 1 y 2, mÿ 2 = g k ( y l ) y 2 y d y,ẏ y 2 y 2 (4) y 1 (0) = a, ẏ 1 (0) = c, y 2 (0) = b, ẏ 2 (0) = d, which approximately describes the behaviour of the damped spring pendulum depicted in Figure 1. Here g is the gravitional acceleration at the earth s surface, m is the mass of the weight attached to the spring, k is the spring constant, l is the length of the spring at its resting position, d is the damping coefficient, and y 1, y 2 denote the coordinates of the weight (the suspension point of the spring is assumed to be the origin). Moreover y := y 2 1 +y 2 2 is the Euclidean norm of y (that is, the length of the pendulum), and y,ẏ = y 1 ẏ 1 +y 2 ẏ 2 is the scalar product of y and ẏ (and thus the length of the projection of ẏ onto y). This equation is stiff, if, for instance, the spring constant is much larger then the gravitational acceleration and also the damping is strong. 0000000000 1111111111 k g Figure 1: Spring pendulum. 14. Rewrite the system (4) as a first order system of ODEs. 15. Consider the numerical solution of the ODE (4) with the implicit Euler method. Formulate explicitly the equations that have to be solved in each time step. In addition, formulate the linear equations that appear when the non-linear equations are solved using the simplified Newton method. 16. Write Matlab or Octave implementations of the two-stage Gauß method and the two-stage Radau IIA method for the solution of non-linear ODEs. Use the simplified Newton method for the solution of the non-linear system that appears in each time step. Test your code on the system (4) and compare the results (and

the necessary step lengths) with the results using an explicit method of a similar order (for instance, the classical Runge Kutta method). Remark: The m-files spring pendulum.m and spring pendulum der.m on the webpage of the lecture contain implementations of the functions defining the system(4) (already written as a first order system of ODEs) and its derivative. The functions take as input one scalar (the time, which is not used) and one vector with four components. The first component vector corresponds to y 1, the second to y 2, the third to ẏ 1, and the fourth to ẏ 2. The coefficients in the implementation are g = 1, m = 1, k = 100, l = 5, d = 1000. Interesting initial conditions might be: y 1 (0) = 0, ẏ 1 (0) = 0 and any intial conditions y 2 (0) < 0 and ẏ 2 (0) R. This setting can be good for testing purposes, as the first variable should remain zero during the whole evolution. y 1 (0) = 0, y 2 (0) = 5, ẏ 1 (0) = c R, ẏ 2 (0) = 0. Then the trajectory of the solution lies almost on a circle. Depending on the size of c, this circle is closed or not. y 1 (0) = 6, y 2 (0) = 6, ẏ 1 (0) = ẏ 2 (0) = 0.