This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Chapter 7 Ordinary Differential Equations Matlab has several different functions for the numerical solution of ordinary dif- ferential equations. This chapter describes the simplest of these functions and then compares all of the functions for efficiency, accuracy, and special features. Stiffness is a subtle concept that plays an important role in these comparisons. 7.1 Integrating Differential Equations The initial value problem for an ordinary differential equation involves finding a function y ( t ) that satisfies dy ( t ) dt = f ( t,y ( t )) together with the initial condition y ( t ) = y . A numerical solution to this problem generates a sequence of values for the indepen- dent variable, t ,t 1 ,... , and a corresponding sequence of values for the dependent variable, y ,y 1 ,... , so that each y n approximates the solution at t n : y n y ( t n ) , n = 0 , 1 ,.... Modern numerical methods automatically determine the step sizes h n = t n +1- t n so that the estimated error in the numerical solution is controlled by a specified tolerance. The fundamental theorem of calculus gives us an important connection be- tween differential equations and integrals: y ( t + h ) = y ( t ) + Z t + h t f ( s,y ( s )) ds. February 16, 2008 1 2 Chapter 7. Ordinary Differential Equations We cannot use numerical quadrature directly to approximate the integral because we do not know the function y ( s ) and so cannot evaluate the integrand. Nevertheless, the basic idea is to choose a sequence of values of h so that this formula allows us to generate our numerical solution. One special case to keep in mind is the situation where f ( t,y ) is a function of t alone. The numerical solution of such simple differential equations is then just a sequence of quadratures: y n +1 = y n + Z t n +1 t n f ( s ) ds. Throughout this chapter, we frequently use dot notation for derivatives: y = dy ( t ) dt and y = d 2 y ( t ) dt 2 . 7.2 Systems of Equations Many mathematical models involve more than one unknown function, and second- and higher order derivatives. These models can be handled by making y ( t ) a vector- valued function of t . Each component is either one of the unknown functions or one of its derivatives. The Matlab vector notation is particularly convenient here. For example, the second-order differential equation describing a simple har- monic oscillator x ( t ) =- x ( t ) becomes two first-order equations. The vector y ( t ) has two components, x ( t ) and its first derivative x ( t ): y ( t ) = x ( t ) x ( t ) . Using this vector, the differential equation is y ( t ) = x ( t )- x ( t ) = y 2 ( t )- y 1 ( t ) . The Matlab function defining the differential equation has t and y as input arguments and should return f ( t,y ) as a column vector. For the harmonic oscillator, the function could be an M-file containing function ydot = harmonic(t,y) ydot = [y(2); -y(1)] A more compact version uses matrix multiplication in an anonymous function,...
View Full Document
- Spring '08