Vector Fields and Solutions to Ordinary Differential Equations using Octave

Size: px
Start display at page:

Download "Vector Fields and Solutions to Ordinary Differential Equations using Octave"

Transcription

1 Vector Fields and Solutions to Ordinary Differential Equations using Andreas Stahel 6th December 29 Contents Vector fields. Vector field for the logistic equation Solutions of ordinary differential equations with lsode Vector field for the equation of a damped pendulum Solution to the pendulum equation The ODE Package on -Forge 6 2. Examples for ode23, ode45 and ode Codes from Lecture Notes 8 3. Using RK45, Runge-Kutta adaptiv Using ode Runge, Runge-Kutta with fixed step Using lsode In these notes you find the methods to generate vector fields with the help of. In addition one of the methods to solve ordinary differential equations is illustrated. The notes assume that you have a recent version of installed. Vector fields A vector field in the plane R 2 is determined by a vector function F x, x 2 F x = F 2 x, x 2 At each point x R 2 the vector F x is attached. One of the possible applications of vectors fields is the visualization of solution of ordinary differential equations.. Vector field for the logistic equation The vector field for the logistic differential equation d dt xt = xt x2 t

2 VECTOR FIELDS 2 is given by Ft, x = x x 2 To visualize this field we have to choose the domain to be used define the functions for the vector field choose how many vectors to draw compute the vectors at the chosen points rescale the length of the vectors generate the graphic on screen save the result in a file The above tasks can be performed with, as shown in the code below with the resulting Figure. t = :. 5 : 8 ; %% choose the time values x = :. 2 : 2 ; %% choose the x values %% define the function function dx = l o g i s t i c x, t dx = x x ˆ 2 ; %% c r e a t e the zero vector f i e l d nt = length t ; nx = length x ; V = zeros nt, nx ; V2 = zeros nt, nx ; %% compute the vector f i e l d for i = : nt for j = : nx V i, j = ; V2 i, j = l o g i s t i c x j, t i ; endfor endfor %% choose the s c a l e f a c t o r s c a l e f a c t o r =. 2 ; f i g u r e ; quiver t, x,v,v2, s c a l e f a c t o r axis [, 8,, 2 ] ; xlabel time t ; ylabel population x grid on %% p r i n t Logistic. png %% p r i n t Logistic. eps.2 Solutions of ordinary differential equations with lsode provides a selection of commands to solve ordinary differential equations, including systems. Here we only use lsode to generate solutions for the differential equations arising from the above vector fields.

3 VECTOR FIELDS population x time t Figure : Vector field for the logistic equation To solve the initial value problem we proceed as follows. d dt xt = xt x2 t with x =.2 Choose the values of time t for which the solution is to be computed. Compute the solution with the command lsode. We may compute more solution by using different initial conditions, e.g. x =.4 and x = 2.. Plot the solutions. The solutions and the vector field can be shown in one graphic. Find the result in Figure 2. T = :. : 8 ; X = lsode l o g i s t i c,. 2,T ; X2 = lsode l o g i s t i c,. 4,T ; X3 = lsode l o g i s t i c, 2.,T ; f i g u r e 3 ; hold off p l o t T, [ X,X2,X3 ] ; grid on ; axis [, 8,, 2 ] ; hold on quiver t, x,v,v2,. 4.3 Vector field for the equation of a damped pendulum For atonomous differential equations the first component of the vector field equals. For general problems this is not the case. As an example we convert the differential equation for a damped pemdulum ÿt = k yt α ẏt

4 VECTOR FIELDS Figure 2: Solutions and vector field for the logistic equation into a system of diffeential equations of order one d dt yt vt = vt k yt α vt and examine the resulting vector field. With the numerical values k = and α =. we have to examine the vector field Fy, v = y. v The code to be used is very similar to the logistic equations and thus shown without any further explanation. y = :.:; %% choose the y values v = :.:; %% choose the v values %% define the function function dy = Fy, v dy = v ; function dv = F2y, v k = ; alpha =. ; dv = k y alpha v ; %% c r e a t e the zero vector f i e l d ny = length y ; nv = length v ; V = zeros ny, nv ; V2 = zeros ny, nv ; %% compute the vector f i e l d for i = : ny for j = : nv V i, j = Fy i, v j ; V2 i, j = F2y i, v j ; endfor endfor

5 VECTOR FIELDS 5 %% choose the s c a l e f a c t o r s c a l e f a c t o r =. 5 ; f i g u r e ; quiver y, v,v, V2, s c a l e f a c t o r grid on ; axis [ min y,max y, min v,max v ] xlabel p o s i t i o n x ; ylabel speed v The only additional feature is the explicit choice of the domain shown in the graphic by the command axis. As can be seen in the left of Figure 3 the vectors at the origin have a small length and thus it is difficult to read of the direction. This can be improved by normalizing all the vectors to have length and then rescale them to have a good length for visalisation. This is done in the code below witrh the result on the right in Figure 3. f i g u r e 2 ; Vlength = s q r t V.ˆ2+V2. ˆ 2 ; Vn = V. / Vlength ; V2n = V2. / Vlength ; quiver y, v, Vn,V2n, s c a l e f a c t o r grid on ; xlabel p o s i t i o n x ; ylabel speed v axis [ min y,max y, min v,max v ].5.5 speed v speed v position x position x Figure 3: Standard and normalized vector field for the pendulum equation.4 Solution to the pendulum equation To determine solutions of the system of differential equations d dt yy vt = vt yt. vt with y v =.9 we have to rewrite the function to be used by lsode. T = :. 5 : 2 5 ; function dy = ODEPendy, t

6 2 THE ODE PACKAGE ON OCTAVE-FORGE 6 k = ; alpha =. ; dy = [ y 2 ; k y alpha y 2 ] ; YV = lsode ODEPend, [ ;. 9 ],T ; f i g u r e 3 ; p l o t T,YV ; grid on xlabel time ; ylabel p o s i t i o n and velocity ; f i g u r e 4 hold off quiver y, v, Vn,V2n, s c a l e f a c t o r grid on axis [ min y,max y, min v,max v ] hold on p l o t YV :,,YV :, 2, r xlabel position ; ylabel velocity ; hold off position and velocity velocity time position Figure 4: One solution and the vector field for the pendulum equation 2 The ODE Package on -Forge The standard command in to solve ordinary differential equations is lsode, as used in the previous section. On Forge at you can find an package with additional commands to solve ODEs. Dowload the package odepkg in a local directory Launch and install the package with the command pkg install odepkg-.6.4.tar.gz Depending on your local configuration you might have to load the package with pkg load odepkg

7 2 THE ODE PACKAGE ON OCTAVE-FORGE 7 With this package many commands from MATLAB are now available in, and some additional commands. Table shows some of the commands. Solver lsode ode23 Description efficient, addaptive solver based on Hindmarsh s work [Hind93] addaptive, explicit,solver, based on Heun s method ode45 addaptive, explicit solver, based on Runge-Kutta method of order 4, resp. 5 ode54 Runge Kutta solver ode78 addaptive, explicit solver, based on Runge-Kutta method of order 7, resp. 8 ode2r ode5r solver for stiff problems, based on Hairer and Wanner s code solver for stiff problems, based on Hairer and Wanner s code Table : commands to solve ordinary differential equations The package provides many additional commands, some of them shown in Table 2. Find a description of the algorithms, their advantages and disadvantages in the file odepkg.pdf, to be found in the subdirectory with the package. Command odeexamples ode23d ode45d ode78d Description launch demos for ordinary differential equations solver for delay differential equations solver for delay differential equations solver for delay differential equations Table 2: Additional commands in the ODE package 2. Examples for ode23, ode45 and ode78 As an example we consider again the pendulum equation d yy vt = dt vt yt. vt with y v = Thus a function file with this function may be generated and then used by all examples below. function dy = ODEPend t, y k = ; alpha =. ; dy = [ y2; k y alpha y 2 ] ; ODEPend.m As a general rule we first choose the parameters for the solver. As a first example we choose a relative tolerance of 3 and an absolute tolerance of 3. We want a graph to be generated while the differential equation is solved. vopt = odeset RelTol, e 3, AbsTol, e 3, NormControl, on,\ ; Then we use ode78 to solve the system of equations..9

8 3 CODES FROM LECTURE NOTES 8 [ 25], [. 9 ], vopt ; The resulting animation and final solution will look rather ragged. Since the Runge Kutta algorithm of order 7 is very efficient, only very few points have to be computed. Thus the graphic does not look nice, but the numerical results are reliable. The command [ 25], [. 9 ], vopt ; will generate a nice looking graph, but require more computation time. With all of the above codes the numerical values will not be returned and are thus not available for further computation. Use the code below if further computations have to be performed. You will find a plot of position and velocity as function of time and a phase plot. vopt = odeset RelTol, e, AbsTol, e, NormControl, on ; [ t, y ] = [ 25], [. 9 ], vopt ; f i g u r e ; p l o t t, y ; xlabel time ; ylabel p o s i t i o n and velocity ; grid on f i g u r e 2 ; p l o t y :,, y :, 2 ; xlabel position ; ylabel velocity ; grid on 3 Codes from Lecture Notes To illustrate the codes presented in the lecture notes we use the example of a diode circuit examined in the notes. The behavior of the diode is given by a function { i = D u = for u u s R D u + u s for u < u s Based on Kirchhoff s law we find the differential equations u h = D u h u in + D u out u h C u out = u in D u out u h C 2 We define the initial conditions and the two function in a script file. u in t = cost. Tend = 3; u = [ ; ] ; We examine an input voltage of function curr = Diode u Rd = ; us =. 7 ; i f u>= us curr =; e l s e curr=rd u+us ; endif function y = c i r c u i t u, t C = ; C2 = ; y = [ /C Diode u sin t Diode u2 u ; cos t /C2 Diode u2 u ] ;

9 3 CODES FROM LECTURE NOTES 9 3. Using RK45, Runge-Kutta adaptiv We can use the adaptive Runge-Kutta algorithm with relative and absolute tolerance of 5 and generate the plot by t = cputime ; [ t, u ] = rk45 c i r c u i t,, Tend, u, e 5,e 5; % Runge Kutta adaptiv timer = cputime t f i g u r e ; p l o t t, u :, 2. grid on ; xlabel time ; ylabel tension ; The result in Figure 5 seems reasonable, but it took 8 seconds of CPU time to compute. 3.2 Using ode Runge, Runge-Kutta with fixed step We can compare the result with a Runge-Kutta calculation with steps, resulting in Figure 5. tfix = linspace, Tend, ; t = cputime ; [ tfix, ufix ] = ode Runge c i r c u i t, tfix, u, ; % Runge Kutta timer = cputime t p l o t tfix, ufix :, 2, t, u :, 2 grid on ; xlabel time ; ylabel tension ; legend u fix, u adapt It took only.5 seconds, but the solution is ragged at the turning points. This can be improved by using intermediate steps between the output times. Use [ tfix, ufix ] = ode Runge c i r c u i t, tfix, u, ; % Runge Kutta to find a competitive solution in.3 seconds. This is one of the rare occasion where a fixed size algorithm outperforms an adaptive algorithm. 3.3 Using lsode We can compare the above result with the performance of lsode. Unfortunately the arguments t and u have to be given in reverse order for lsode and the above codes and thus the header of the function circuit has to be modified slightly. We have to specify the tolerances. With a computation time of.48 seconds we find a good solution. This illustrates the quality of the algorithm in lsode.m. Tend = 3; u = [ ; ] ; DoubleTensionLSODE.m function curr = Diode u Rd = ; us =. 7 ; i f u>= us curr =; e l s e curr=rd u+us ; endif function y = c i r c u i t u, t C = ; C2 = ; y = [ /C Diode u sin t Diode u2 u ; cos t /C2 Diode u2 u ] ; t = linspace, Tend, ;

10 REFERENCES 3 25 u fix u adapt tension time Figure 5: Solution for the diode circuit with Runge-Kutta, fixed step and adaptive lsode options absolute lsode options r e l a t i v e t o l e r a n c e, e 5; t o l e r a n c e, e 5; t = cputime ; u = lsode c i r c u i t, u, t ; timer = cputime t p l o t t, u :, 2 grid on ; xlabel time ; ylabel tension ; In the previous section the codes and data files in Table 3 were used. filename ode Euler.m ode Heun.m ode Runge.m rk45.m DoubleTension.m DoubleTensionLSODE.m function algorithm of Euler, fixed step size algorithm of Heun, fixed step size algorithm of Runge-Kutta, fixed step size adaptive Runge Kutta algorithm sample code for the diode circuit using lsode Table 3: Codes and data files References [Hind93] A. C. Hindmarsh and K. Radhakrishnan. Description and Use of LSODE, the Livermore Solver for Ordinary Differential Equations. NASA, 993.

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

Vector Fields and Solutions to Ordinary Differential Equations using MATLAB/Octave Vector Fields and Solutions to Ordinary Differential Equations using MATLAB/Octave Andreas Stahel 5th December 27 Contents Vector field for the logistic equation 2 Solutions of ordinary differential equations

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

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

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

More information

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP MATLAB sessions: Laboratory 4 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

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

Chapter 1: Introduction

Chapter 1: Introduction Chapter 1: Introduction Definition: A differential equation is an equation involving the derivative of a function. If the function depends on a single variable, then only ordinary derivatives appear and

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

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

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

MECH : a Primer for Matlab s ode suite of functions

MECH : a Primer for Matlab s ode suite of functions Objectives MECH 4-563: a Primer for Matlab s ode suite of functions. Review the fundamentals of initial value problems and why numerical integration methods are needed.. Introduce the ode suite of numerical

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

2 Solving Ordinary Differential Equations Using MATLAB

2 Solving Ordinary Differential Equations Using MATLAB Penn State Erie, The Behrend College School of Engineering E E 383 Signals and Control Lab Spring 2008 Lab 3 System Responses January 31, 2008 Due: February 7, 2008 Number of Lab Periods: 1 1 Objective

More information

Syntax. Arguments. Solve m oderately stifo DEsand DAEs;trapezoidalrule. 1 of :34

Syntax. Arguments. Solve m oderately stifo DEsand DAEs;trapezoidalrule. 1 of :34 1 of 8 09.01.2016 09:34 Solve m oderately stifo DEsand DAEs;trapezoidalrule Syntax [T,Y] = solver(odefun,tspan,y0) [T,Y] = solver(odefun,tspan,y0,options) [T,Y,TE,YE,IE] = solver(odefun,tspan,y0,options)

More information

Experiment 1: Linear Regression

Experiment 1: Linear Regression Experiment 1: Linear Regression August 27, 2018 1 Description This first exercise will give you practice with linear regression. These exercises have been extensively tested with Matlab, but they should

More information

MAT 275 Laboratory 6 Forced Equations and Resonance

MAT 275 Laboratory 6 Forced Equations and Resonance MAT 275 Laboratory 6 Forced Equations and Resonance In this laboratory we take a deeper look at second-order nonhomogeneous equations. We will concentrate on equations with a periodic harmonic forcing

More information

Lesson 14: Van der Pol Circuit and ode23s

Lesson 14: Van der Pol Circuit and ode23s Lesson 4: Van der Pol Circuit and ode3s 4. Applied Problem. A series LRC circuit when coupled via mutual inductance with a triode circuit can generate a sequence of pulsing currents that have very rapid

More information

Ordinary differential equations - Initial value problems

Ordinary differential equations - Initial value problems Education has produced a vast population able to read but unable to distinguish what is worth reading. G.M. TREVELYAN Chapter 6 Ordinary differential equations - Initial value problems In this chapter

More information

Laboratory 10 Forced Equations and Resonance

Laboratory 10 Forced Equations and Resonance MATLAB sessions: Laboratory 9 Laboratory Forced Equations and Resonance ( 3.6 of the Edwards/Penney text) In this laboratory we take a deeper look at second-order nonhomogeneous equations. We will concentrate

More information

Mathematics 22: Lecture 11

Mathematics 22: Lecture 11 Mathematics 22: Lecture 11 Runge-Kutta Dan Sloughter Furman University January 25, 2008 Dan Sloughter (Furman University) Mathematics 22: Lecture 11 January 25, 2008 1 / 11 Order of approximations One

More information

Numerical Analysis II. Problem Sheet 12

Numerical Analysis II. Problem Sheet 12 P. Grohs S. Hosseini Ž. Kereta Spring Term 2015 Numerical Analysis II ETH Zürich D-MATH Problem Sheet 12 Problem 12.1 The Exponential Runge-Kutta Method Consider the exponential Runge Kutta single-step

More information

Ordinary Differential Equations (ODE)

Ordinary Differential Equations (ODE) Ordinary Differential Equations (ODE) Why study Differential Equations? Many physical phenomena are best formulated mathematically in terms of their rate of change. Motion of a swinging pendulum Bungee-jumper

More information

Solving ODEs and PDEs in MATLAB. Sören Boettcher

Solving ODEs and PDEs in MATLAB. Sören Boettcher 16.02.2009 Introduction Quick introduction to syntax ODE in the form of Initial Value Problems (IVP) what equations can handle how to code into how to choose the right solver how to get the solver to do

More information

Computer lab for MAN460

Computer lab for MAN460 Computer lab for MAN460 (version 20th April 2006, corrected 20 May) Prerequisites Matlab is rather user friendly, and to do the first exercises, it is enough to write an m-file consisting of two lines,

More information

Manifesto on Numerical Integration of Equations of Motion Using Matlab

Manifesto on Numerical Integration of Equations of Motion Using Matlab Manifesto on Numerical Integration of Equations of Motion Using Matlab C. Hall April 11, 2002 This handout is intended to help you understand numerical integration and to put it into practice using Matlab

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

Initial Value Problems

Initial Value Problems Numerical Analysis, lecture 13: Initial Value Problems (textbook sections 10.1-4, 10.7) differential equations standard form existence & uniqueness y 0 y 2 solution methods x 0 x 1 h h x 2 y1 Euler, Heun,

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

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

Ordinary Differential Equations: Initial Value problems (IVP)

Ordinary Differential Equations: Initial Value problems (IVP) Chapter Ordinary Differential Equations: Initial Value problems (IVP) Many engineering applications can be modeled as differential equations (DE) In this book, our emphasis is about how to use computer

More information

AMS 27L LAB #8 Winter 2009

AMS 27L LAB #8 Winter 2009 AMS 27L LAB #8 Winter 29 Solving ODE s in Matlab Objectives:. To use Matlab s ODE Solvers 2. To practice using functions and in-line functions Matlab s ODE Suite Matlab offers a suite of ODE solvers including:

More information

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

AM205: Assignment 3 (due 5 PM, October 20) AM25: Assignment 3 (due 5 PM, October 2) For this assignment, first complete problems 1, 2, 3, and 4, and then complete either problem 5 (on theory) or problem 6 (on an application). If you submit answers

More information

4.4 Computing π, ln 2 and e

4.4 Computing π, ln 2 and e 252 4.4 Computing π, ln 2 and e The approximations π 3.1415927, ln 2 0.69314718, e 2.7182818 can be obtained by numerical methods applied to the following initial value problems: (1) y = 4, 1 + x2 y(0)

More information

. For each initial condition y(0) = y 0, there exists a. unique solution. In fact, given any point (x, y), there is a unique curve through this point,

. For each initial condition y(0) = y 0, there exists a. unique solution. In fact, given any point (x, y), there is a unique curve through this point, 1.2. Direction Fields: Graphical Representation of the ODE and its Solution Section Objective(s): Constructing Direction Fields. Interpreting Direction Fields. Definition 1.2.1. A first order ODE of the

More information

Chap. 20: Initial-Value Problems

Chap. 20: Initial-Value Problems Chap. 20: Initial-Value Problems Ordinary Differential Equations Goal: to solve differential equations of the form: dy dt f t, y The methods in this chapter are all one-step methods and have the general

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

24, B = 59 24, A = 55

24, B = 59 24, A = 55 Math 128a - Homework 8 - Due May 2 1) Problem 8.4.4 (Page 555) Solution: As discussed in the text, the fourth-order Adams-Bashforth formula is a formula of the type x n+1 = x n + h[af n + Bf n 1 + Cf n

More information

Delay Differential Equations Part I: Constant Lags

Delay Differential Equations Part I: Constant Lags Delay Differential Equations Part I: Constant Lags L.F. Shampine Department of Mathematics Southern Methodist University Dallas, Texas 75275 shampine@smu.edu www.faculty.smu.edu/shampine Delay Differential

More information

Ordinary Differential Equations (ode)

Ordinary Differential Equations (ode) Ordinary Differential Equations (ode) Numerical Methods for Solving Initial condition (ic) problems and Boundary value problems (bvp) What is an ODE? =,,...,, yx, dx dx dx dx n n 1 n d y d y d y In general,

More information

Solving systems of ODEs with Matlab

Solving systems of ODEs with Matlab Solving systems of ODEs with Matlab James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 20, 2013 Outline 1 Systems of ODEs 2 Setting Up

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

Using Matlab to integrate Ordinary Differential Equations (ODEs)

Using Matlab to integrate Ordinary Differential Equations (ODEs) Using Matlab to integrate Ordinary Differential Equations (ODEs) Erica McEvoy (Dated: June 17, 2009) 1. INTRODUCTION Ordinary differential equations tend to arise whenever you need to model changing quantities

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

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

The family of Runge Kutta methods with two intermediate evaluations is defined by AM 205: lecture 13 Last time: Numerical solution of ordinary differential equations Today: Additional ODE methods, boundary value problems Thursday s lecture will be given by Thomas Fai Assignment 3 will

More information

1 Introduction to MATLAB

1 Introduction to MATLAB L3 - December 015 Solving PDEs numerically (Reports due Thursday Dec 3rd, carolinemuller13@gmail.com) In this project, we will see various methods for solving Partial Differential Equations (PDEs) using

More information

Logistic Map, Euler & Runge-Kutta Method and Lotka-Volterra Equations

Logistic Map, Euler & Runge-Kutta Method and Lotka-Volterra Equations Logistic Map, Euler & Runge-Kutta Method and Lotka-Volterra Equations S. Y. Ha and J. Park Department of Mathematical Sciences Seoul National University Sep 23, 2013 Contents 1 Logistic Map 2 Euler and

More information

MAT 275 Laboratory 6 Forced Equations and Resonance

MAT 275 Laboratory 6 Forced Equations and Resonance MATLAB sessions: Laboratory 6 MAT 275 Laboratory 6 Forced Equations and Resonance In this laboratory we take a deeper look at second-order nonhomogeneous equations. We will concentrate on equations with

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

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

13 Numerical Solution of ODE s

13 Numerical Solution of ODE s 13 NUMERICAL SOLUTION OF ODE S 28 13 Numerical Solution of ODE s In simulating dynamical systems, we frequently solve ordinary differential equations. These are of the form dx = f(t, x), dt where the function

More information

ES205 Analysis and Design of Engineering Systems: Lab 1: An Introductory Tutorial: Getting Started with SIMULINK

ES205 Analysis and Design of Engineering Systems: Lab 1: An Introductory Tutorial: Getting Started with SIMULINK ES205 Analysis and Design of Engineering Systems: Lab 1: An Introductory Tutorial: Getting Started with SIMULINK What is SIMULINK? SIMULINK is a software package for modeling, simulating, and analyzing

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

Octave at BFH-TI Biel. Andreas Stahel, Bern University of Applied Sciences, Switzerland

Octave at BFH-TI Biel. Andreas Stahel, Bern University of Applied Sciences, Switzerland at BFH-TI Biel Andreas Stahel, Bern University of Applied Sciences, Switzerland Version of 7th January 218 Foreword These lecture notes were used at my school to familiarize students with, to be used to

More information

Numerical method for approximating the solution of an IVP. Euler Algorithm (the simplest approximation method)

Numerical method for approximating the solution of an IVP. Euler Algorithm (the simplest approximation method) Section 2.7 Euler s Method (Computer Approximation) Key Terms/ Ideas: Numerical method for approximating the solution of an IVP Linear Approximation; Tangent Line Euler Algorithm (the simplest approximation

More information

ODE Runge-Kutta methods

ODE Runge-Kutta methods ODE Runge-Kutta methods The theory (very short excerpts from lectures) First-order initial value problem We want to approximate the solution Y(x) of a system of first-order ordinary differential equations

More information

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

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University Part 6 Chapter 20 Initial-Value Problems PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright The McGraw-Hill Companies, Inc. Permission required for reproduction

More information

Mechanics of Structures (CE130N) Lab 3

Mechanics of Structures (CE130N) Lab 3 UNIVERSITY OF CALIFORNIA AT BERKELEY CE 130N, Spring 2009 Department of Civil and Environmental Engineering Prof. S. Govindjee and Dr. T. Koyama Structural Engineering, Mechanics and Materials Lab 3 1

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

Differential Equations (Mathematics) Evaluate the numerical solution using output of ODE solvers.

Differential Equations (Mathematics) Evaluate the numerical solution using output of ODE solvers. Differential Equations (Mathematics) Página 1 de 2 Mathematics ODE Function Summary Initial Value ODE Problem Solvers These are the MATLAB initial value problem solvers. The table lists the kind of problem

More information

Appendix 3B MATLAB Functions for Modeling and Time-domain analysis

Appendix 3B MATLAB Functions for Modeling and Time-domain analysis Appendix 3B MATLAB Functions for Modeling and Time-domain analysis MATLAB control system Toolbox contain the following functions for the time-domain response step impulse initial lsim gensig damp ltiview

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

Memristor Based Chaotic Circuits

Memristor Based Chaotic Circuits Memristor Based Chaotic Circuits Bharathwaj Muthuswamy Electrical Engineering and Computer Sciences University of California at Berkeley Technical Report No. UCB/EECS-2009-6 http://www.eecs.berkeley.edu/pubs/techrpts/2009/eecs-2009-6.html

More information

PSTricks. pst-ode. A PSTricks package for solving initial value problems for sets of Ordinary Differential Equations(ODE), v0.12.

PSTricks. pst-ode. A PSTricks package for solving initial value problems for sets of Ordinary Differential Equations(ODE), v0.12. PSTricks pst-ode A PSTricks package for solving initial value problems for sets of Ordinary Differential Equations(ODE), v0.12 https://gitlab.com/agrahn/pst-ode 7th June 2018 Package author(s): Alexander

More information

Introduction to ODEs in Matlab. Jeremy L. Marzuola Charles Talbot Benjamin Wilson

Introduction to ODEs in Matlab. Jeremy L. Marzuola Charles Talbot Benjamin Wilson Introduction to ODEs in Matlab Jeremy L. Marzuola Charles Talbot Benjamin Wilson E-mail address: marzuola@math.unc.edu Department of Mathematics, UNC-Chapel Hill, CB#3250 Phillips Hall, Chapel Hill, NC

More information

Solving Ordinary Differential Equations

Solving Ordinary Differential Equations Solving Ordinary Differential Equations Sanzheng Qiao Department of Computing and Software McMaster University March, 2014 Outline 1 Initial Value Problem Euler s Method Runge-Kutta Methods Multistep Methods

More information

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

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University Part 6 Chapter 20 Initial-Value Problems PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright The McGraw-Hill Companies, Inc. Permission required for reproduction

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

Lecture 5b: Starting Matlab

Lecture 5b: Starting Matlab Lecture 5b: Starting Matlab James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University August 7, 2013 Outline 1 Resources 2 Starting Matlab 3 Homework

More information

Ordinary Differential equations

Ordinary Differential equations Chapter 1 Ordinary Differential equations 1.1 Introduction to Ordinary Differential equation In mathematics, an ordinary differential equation (ODE) is an equation which contains functions of only one

More information

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill 12.010 Computational Methods of Scientific Programming Lecturers Thomas A Herring Chris Hill Overview Today Solution of ordinary differential equations with Mathematica and Matlab. Examine formulations:

More information

An Introduction to Xcos

An Introduction to Xcos A. B. Raju Ph.D Professor and Head, Electrical and Electronics Engineering Department, B. V. B. College of Engineering and Technology, HUBLI-580 031, KARNATAKA abraju@bvb.edu 28 th September 2010 Outline

More information

Computational Methods in Plasma Physics

Computational Methods in Plasma Physics Computational Methods in Plasma Physics Richard Fitzpatrick Institute for Fusion Studies University of Texas at Austin Purpose of Talk Describe use of numerical methods to solve simple problem in plasma

More information

2 Ordinary Differential Equations: Initial Value Problems

2 Ordinary Differential Equations: Initial Value Problems Ordinar Differential Equations: Initial Value Problems Read sections 9., (9. for information), 9.3, 9.3., 9.3. (up to p. 396), 9.3.6. Review questions 9.3, 9.4, 9.8, 9.9, 9.4 9.6.. Two Examples.. Foxes

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

Ordinary differential equation II

Ordinary differential equation II Ordinary Differential Equations ISC-5315 1 Ordinary differential equation II 1 Some Basic Methods 1.1 Backward Euler method (implicit method) The algorithm looks like this: y n = y n 1 + hf n (1) In contrast

More information

Temperature measurement

Temperature measurement Luleå University of Technology Johan Carlson Last revision: July 22, 2009 Measurement Technology and Uncertainty Analysis - E7021E Lab 3 Temperature measurement Introduction In this lab you are given a

More information

Two applications of macros in PSTricks

Two applications of macros in PSTricks Two applications of macros in PSTricks Le Phuong Quan (Cantho University, Vietnam) April 5, 00 Contents. Drawing approximations to the area under a graph by rectangles.. 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

Laboratory 1. Solving differential equations with nonzero initial conditions

Laboratory 1. Solving differential equations with nonzero initial conditions Laboratory 1 Solving differential equations with nonzero initial conditions 1. Purpose of the exercise: - learning symbolic and numerical methods of differential equations solving with MATLAB - using Simulink

More information

Chapter 1 Fundamental Concepts

Chapter 1 Fundamental Concepts Chapter 1 Fundamental Concepts Signals A signal is a pattern of variation of a physical quantity as a function of time, space, distance, position, temperature, pressure, etc. These quantities are usually

More information

Lecture 1. Scott Pauls 1 3/28/07. Dartmouth College. Math 23, Spring Scott Pauls. Administrivia. Today s material.

Lecture 1. Scott Pauls 1 3/28/07. Dartmouth College. Math 23, Spring Scott Pauls. Administrivia. Today s material. Lecture 1 1 1 Department of Mathematics Dartmouth College 3/28/07 Outline Course Overview http://www.math.dartmouth.edu/~m23s07 Matlab Ordinary differential equations Definition An ordinary differential

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

The Spring Pendulum. Nick Whitman. May 16, 2000

The Spring Pendulum. Nick Whitman. May 16, 2000 The Spring Pendulum Nick Whitman May 16, 2 Abstract The spring pendulum is analyzed in three dimensions using differential equations and the Ode45 solver in Matlab. Newton s second law is used to write

More information

University of Alberta ENGM 541: Modeling and Simulation of Engineering Systems Laboratory #5

University of Alberta ENGM 541: Modeling and Simulation of Engineering Systems Laboratory #5 University of Alberta ENGM 54: Modeling and Simulation of Engineering Systems Laboratory #5 M.G. Lipsett, Updated 00 Integration Methods with Higher-Order Truncation Errors with MATLAB MATLAB is capable

More information

Numerical Solution of Differential Equations

Numerical Solution of Differential Equations 1 Numerical Solution of Differential Equations A differential equation (or "DE") contains derivatives or differentials. In a differential equation the unknown is a function, and the differential equation

More information

4. Numerical analysis II

4. Numerical analysis II 4. Numerical analysis II 1. Numerical differentiation 2. Numerical integration 3. Ordinary differential equations (ODEs). First order ODEs 4. Numerical methods for initial value problems (individual ODEs)

More information

Matlab Section. November 8, 2005

Matlab Section. November 8, 2005 Matlab Section November 8, 2005 1 1 General commands Clear all variables from memory : clear all Close all figure windows : close all Save a variable in.mat format : save filename name of variable Load

More information

FIRST-ORDER ORDINARY DIFFERENTIAL EQUATIONS II: Graphical and Numerical Methods David Levermore Department of Mathematics University of Maryland

FIRST-ORDER ORDINARY DIFFERENTIAL EQUATIONS II: Graphical and Numerical Methods David Levermore Department of Mathematics University of Maryland FIRST-ORDER ORDINARY DIFFERENTIAL EQUATIONS II: Graphical and Numerical Methods David Levermore Department of Mathematics University of Maryland 9 January 0 Because the presentation of this material in

More information

AMS 27L LAB #6 Winter 2009

AMS 27L LAB #6 Winter 2009 AMS 27L LAB #6 Winter 2009 Symbolically Solving Differential Equations Objectives: 1. To learn about the MATLAB Symbolic Solver 2. To expand knowledge of solutions to Diff-EQs 1 Symbolically Solving Differential

More information

Solution. Your sketch should show both x and y axes marked from 5 to 5 and circles of radius 1, 3, and 5 centered at the origin.

Solution. Your sketch should show both x and y axes marked from 5 to 5 and circles of radius 1, 3, and 5 centered at the origin. Solutions of the Sample Problems for the First In-Class Exam Math 246, Fall 208, Professor David Levermore () (a) Sketch the graph that would be produced by the following Matlab command. fplot(@(t) 2/t,

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

CPS 5310: Parameter Estimation. Natasha Sharma, Ph.D.

CPS 5310: Parameter Estimation. Natasha Sharma, Ph.D. Example Suppose our task is to determine the net income for year 2019 based on the net incomes given below Year Net Income 2016 48.3 million 2017 90.4 million 2018 249.9 million Last lecture we tried to

More information

APPLICATIONS OF FD APPROXIMATIONS FOR SOLVING ORDINARY DIFFERENTIAL EQUATIONS

APPLICATIONS OF FD APPROXIMATIONS FOR SOLVING ORDINARY DIFFERENTIAL EQUATIONS LECTURE 10 APPLICATIONS OF FD APPROXIMATIONS FOR SOLVING ORDINARY DIFFERENTIAL EQUATIONS Ordinary Differential Equations Initial Value Problems For Initial Value problems (IVP s), conditions are specified

More information

Solutions of the Sample Problems for the First In-Class Exam Math 246, Fall 2017, Professor David Levermore

Solutions of the Sample Problems for the First In-Class Exam Math 246, Fall 2017, Professor David Levermore Solutions of the Sample Problems for the First In-Class Exam Math 246, Fall 207, Professor David Levermore () (a) Give the integral being evaluated by the following Matlab command. int( x/(+xˆ4), x,0,inf)

More information

MATH2071: LAB 3: Implicit ODE methods

MATH2071: LAB 3: Implicit ODE methods MATH2071: LAB 3: Implicit ODE methods 1 Introduction Introduction Exercise 1 Stiff Systems Exercise 2 Direction Field Plots Exercise 3 The Backward Euler Method Exercise 4 Newton s method Exercise 5 The

More information

Numerical Analysis II. Problem Sheet 9

Numerical Analysis II. Problem Sheet 9 H. Ammari W. Wu S. Yu Spring Term 08 Numerical Analysis II ETH Zürich D-MATH Problem Sheet 9 Problem 9. Extrapolation of the Implicit Mid-Point Rule. Taking the implicit mid-point rule as a basis method,

More information

Lab 13: Ordinary Differential Equations

Lab 13: Ordinary Differential Equations EGR 53L - Fall 2009 Lab 13: Ordinary Differential Equations 13.1 Introduction This lab is aimed at introducing techniques for solving initial-value problems involving ordinary differential equations using

More information

Research Computing with Python, Lecture 7, Numerical Integration and Solving Ordinary Differential Equations

Research Computing with Python, Lecture 7, Numerical Integration and Solving Ordinary Differential Equations Research Computing with Python, Lecture 7, Numerical Integration and Solving Ordinary Differential Equations Ramses van Zon SciNet HPC Consortium November 25, 2014 Ramses van Zon (SciNet HPC Consortium)Research

More information

10.34: Numerical Methods Applied to Chemical Engineering. Lecture 19: Differential Algebraic Equations

10.34: Numerical Methods Applied to Chemical Engineering. Lecture 19: Differential Algebraic Equations 10.34: Numerical Methods Applied to Chemical Engineering Lecture 19: Differential Algebraic Equations 1 Recap Differential algebraic equations Semi-explicit Fully implicit Simulation via backward difference

More information

Lesson 9: Predator-Prey and ode45

Lesson 9: Predator-Prey and ode45 Lesson 9: Predator-Prey and ode45 9.1 Applied Problem. In this lesson we will allow for more than one population where they depend on each other. One population could be the predator such as a fox, and

More information

A Glimpse at Scipy FOSSEE. June Abstract This document shows a glimpse of the features of Scipy that will be explored during this course.

A Glimpse at Scipy FOSSEE. June Abstract This document shows a glimpse of the features of Scipy that will be explored during this course. A Glimpse at Scipy FOSSEE June 010 Abstract This document shows a glimpse of the features of Scipy that will be explored during this course. 1 Introduction SciPy is open-source software for mathematics,

More information