MATH 100 Introduction to the Profession

Similar documents
Calculus and Parametric Equations

MATH 100 Introduction to the Profession

APPM 2460 CHAOTIC DYNAMICS

Predicting the future with Newton s Second Law

LAB #6 The Swaying Building

Lesson 14: Van der Pol Circuit and ode23s

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

Ordinary Differential Equations

3.3. SYSTEMS OF ODES 1. y 0 " 2y" y 0 + 2y = x1. x2 x3. x = y(t) = c 1 e t + c 2 e t + c 3 e 2t. _x = A x + f; x(0) = x 0.

Numerical Methods for the Solution of Differential Equations

Math 333 Qualitative Results: Forced Harmonic Oscillators

M A : Ordinary Differential Equations

Initial value problems for ordinary differential equations

Even-Numbered Homework Solutions

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

Parametric Functions and Vector Functions (BC Only)

Math 3313: Differential Equations Second-order ordinary differential equations

APPLICATIONS OF FD APPROXIMATIONS FOR SOLVING ORDINARY DIFFERENTIAL EQUATIONS

Ch 3.7: Mechanical & Electrical Vibrations

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

Why are Discrete Maps Sufficient?

Math 307 A - Spring 2015 Final Exam June 10, 2015

Outline. Calculus for the Life Sciences. What is a Differential Equation? Introduction. Lecture Notes Introduction to Differential Equa

Section 9.3 Phase Plane Portraits (for Planar Systems)

Lecture for Week 6 (Secs ) Derivative Miscellany I

Physics GRE Practice

Lesson 11: Mass-Spring, Resonance and ode45

AP Physics C Summer Homework. Questions labeled in [brackets] are required only for students who have completed AP Calculus AB

Math 343 Lab 7: Line and Curve Fitting

Physics 115/242 Comparison of methods for integrating the simple harmonic oscillator.

Application 6.5B Period Doubling and Chaos in Mechanical Systems

Differential Equations

M A : Ordinary Differential Equations

MTH 464: Computational Linear Algebra

ENGI 9420 Lecture Notes 4 - Stability Analysis Page Stability Analysis for Non-linear Ordinary Differential Equations

Homogeneous Equations with Constant Coefficients

Math 11 Fall 2016 Section 1 Monday, September 19, Definition: A vector parametric equation for the line parallel to vector v = x v, y v, z v

Vector Functions & Space Curves MATH 2110Q

Kinematics Introduction

MATH 350: Introduction to Computational Mathematics

Learning Objectives for Math 166

Thursday, August 4, 2011

APPLICATIONS OF SECOND-ORDER DIFFERENTIAL EQUATIONS

Math Numerical Analysis

APPM 2360: Final Exam 10:30am 1:00pm, May 6, 2015.

Math 106 Answers to Exam 3a Fall 2015

Section Mass Spring Systems

Parametric Curves You Should Know

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

Calculus for the Life Sciences

6.11 MECHANICS 3, M3 (4763) A2

Chapter 6 - Ordinary Differential Equations

OPTIMAL CONTROL. Sadegh Bolouki. Lecture slides for ECE 515. University of Illinois, Urbana-Champaign. Fall S. Bolouki (UIUC) 1 / 28

Brenda Rubenstein (Physics PhD)

Ordinary Differential Equations (ODEs) Background. Video 17

The Princeton Review AP Calculus BC Practice Test 2

Answers and Hints to Review Questions for Test (a) Find the general solution to the linear system of differential equations Y = 2 ± 3i.

converges to a root, it may not always be the root you have in mind.

Multiple Choice. Circle the best answer. No work needed. No partial credit available. is continuous.

Final 09/14/2017. Notes and electronic aids are not allowed. You must be seated in your assigned row for your exam to be valid.

Note: Unless otherwise specified, the domain of a function f is assumed to be the set of all real numbers x for which f (x) is a real number.

AP Calculus BC Scope & Sequence

Lecture 6: Differential Equations Describing Vibrations

Additional Homework Problems

Math 266: Phase Plane Portrait

MB4018 Differential equations

Chapter 14 Oscillations. Copyright 2009 Pearson Education, Inc.

LECTURE 8: DYNAMICAL SYSTEMS 7

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

Introduction. Math Calculus 1 section 2.1 and 2.2. Julian Chan. Department of Mathematics Weber State University

= 3, the vertical velocty is. (x(t), y(t)) = (1 + 3t, 2 + 4t) for t [0, 1],

Chapter 1: Introduction

Sinusoids. Amplitude and Magnitude. Phase and Period. CMPT 889: Lecture 2 Sinusoids, Complex Exponentials, Spectrum Representation

1) SIMPLE HARMONIC MOTION/OSCILLATIONS

Practice Problems For Test 3

CMPT 889: Lecture 2 Sinusoids, Complex Exponentials, Spectrum Representation

Differentiation of Parametric Space Curves. Goals: Velocity in parametric curves Acceleration in parametric curves

10.3 Parametric Equations. 1 Math 1432 Dr. Almus

Ordinary differential equations - Initial value problems

Chapter 14 Oscillations

First Order Systems of Linear Equations. or ODEs of Arbitrary Order

AP Calculus BC Syllabus Course Overview

APPM 2360 Section Exam 3 Wednesday November 19, 7:00pm 8:30pm, 2014

MATHEMATICAL MODELLING, MECHANICS AND MOD- ELLING MTHA4004Y

Practice Problems For Test 3

Old Math 330 Exams. David M. McClendon. Department of Mathematics Ferris State University

Differential Equations

MATH 353 LECTURE NOTES: WEEK 1 FIRST ORDER ODES

Math 266: Ordinary Differential Equations

F = ma, F R + F S = mx.

Section Vector Functions and Space Curves

MATH 350: Introduction to Computational Mathematics

Topic 2-2: Derivatives of Vector Functions. Textbook: Section 13.2, 13.4

Calculus from Graphical, Numerical, and Symbolic Points of View, 2e Arnold Ostebee & Paul Zorn

The Plan. Initial value problems (ivps) for ordinary differential equations (odes) Review of basic methods You are here: Hamiltonian systems

Grade 11/12 Math Circles Conics & Applications The Mathematics of Orbits Dr. Shahla Aliakbari November 18, 2015

Worksheet 4.2: Introduction to Vector Fields and Line Integrals

Pre-Class. List everything you remember about circular motion...

Question: Total. Points:

Chapter 13 Lecture. Essential University Physics Richard Wolfson 2 nd Edition. Oscillatory Motion Pearson Education, Inc.

Transcription:

MATH 100 Introduction to the Profession Differential Equations in MATLAB Greg Fasshauer Department of Applied Mathematics Illinois Institute of Technology Fall 2012 fasshauer@iit.edu MATH 100 ITP 1

What is a Differential Equation? Answer Unlike an algebraic equation such as Differential Equations 2x = x 2 + 1 x 2 2x + 1 = 0 (x 1) 2 = 0 x = 1, or a transcendental equation such as x = cos(x) fixed point iteration = x = 0.7390851332151606416553..., where the unknown quantities are given by a number, x, and algebraic or transcendental expressions in terms of x, the unknown quantity in a differential equation is a function along with some of its derivatives, and therefore the solution is also a function. For example, we saw earlier that P (t) = rp(t), P(0) = P 0 P(t) = P 0 e rt, t > 0. fasshauer@iit.edu MATH 100 ITP 2

Differential Equations Since derivatives can be interpreted as rates of change, differential equations are used to express problems such as change in account balance in relation to the amount of money in an account (as a function of time) A (t) = ra(t) = A(t) =... population growth rate in relation to the size of a population (as a function of time) ( P (t) = 1 P(t) ) P(t) = P(t) =... C acceleration of a body in relation to the position of the body (as a function of time) x (t) = x(t) = x(t) =... change in temperature of a body (as a function of location and time) T (x, t) t = k 2 2 T (x, t) x 2 = T (x, t) =... fasshauer@iit.edu MATH 100 ITP 3

Slope Fields Visualizing Differential Equations Slope fields are a great way to visualize what s going on in a differential equation. A differential equation by itself does not constitute a well-posed problem. There are graphs of many different functions that fit into any given slope field. A slope field usually represents a family of infinitely many solutions to the differential equation. In order to guarantee a unique solution (and make the problem well-posed) we need to specify an initial condition (or initial point). fasshauer@iit.edu MATH 100 ITP 4

Slope Fields We can use the Mathematica Demo SlopeFieldsEdited.cdf to illustrate, e.g., y = 3y (i.e., A (t) = ra(t)) y = ( 1 y ) ( ) 3 y (i.e., P (t) = 1 P(t) C P(t)) Other examples of real life slope fields are grade markers along a road [ExM] speed sensors along a highway (group project) complex flow visualization fasshauer@iit.edu MATH 100 ITP 5

A Real Slope Field Shock wave on I-680 in Walnut Creek, CA, during rush hour [Coifman]. The graph shows distance traveled (vertical axis) as a function of time (horizontal axis). Each yellow line describes the path of an individual vehicle. Line slopes correspond to vehicle speed at any position and time (background color ranges from black=0 mph to blue=40 mph). fasshauer@iit.edu MATH 100 ITP 6

Space Orbits via Differential Equations What should a slope field for a circular orbit look like? Point (x(t), y(t)) Tangent (x (t), y (t)) (1,0) (0,1) (0,1) (-1,0) (-1,0) (0,-1) (0,-1) (1,0) Differential equations: x (t) = y(t) y (t) = x(t) Which functions x = x(t) and y = y(t) satisfy this system of differential equations? x(t) = cos(t), y(t) = sin(t) Remark In more realistic applications these orbits are derived based on physical laws (such as Kepler s or Newton s laws of motion). fasshauer@iit.edu MATH 100 ITP 7

Space Orbits via Differential Equations Standard form of first-order ODE systems Instead of x (t) = y(t) y (t) = x(t) one usually changes over to vector notation. We introduce y(t) = [y 1 (t), y 2 (t)] T = [x(t), y(t)] T, so that the circle orbit is described by y 1 (t) = y 2(t) y 2 (t) = y 1(t). If we abbreviate f (t, y(t)) = [ y 2 (t), y 1 (t)] T, then we get y (t) = f (t, y(t)). This is the standard form of a (system of) ordinary differential equation, and also the way MATLAB expects to get an ODE. fasshauer@iit.edu MATH 100 ITP 8

Orbits via ode23 Chapter 15 of Experiments with MATLAB Space Orbits via Differential Equations The system y 1 (t) = y 2(t) y 2 (t) = y 1(t) with f (t, y(t)) = [ y 2 (t), y 1 (t)] T can be implemented in MATLAB: mycircle = @(t,y) [-y(2); y(1)]; tspan = [0 2*pi]; % range for t y0 = [1; 0]; % starting point [t y] = ode23(mycircle,tspan,y0); plot(y(:,1),y(:,2), -o ) axis(1.1*[-1 1-1 1]) axis square % f(t,y(t)) An alternate form using a MATLAB function M-file is described in [ExM]. fasshauer@iit.edu MATH 100 ITP 9

Space Orbits via Differential Equations What does the following change 1 do? y 1 (t) = y 2(t) y 2 (t) = y 1(t) We have y y. y 1 (t) = y 2(t) y 2 (t) = y 1(t) The orientation of the orbit is reversed (counterclockwise clockwise). The solution is given by y 1 (t) = cos(t) y 2 (t) = sin(t) Try this out in MATLAB. y 1 (t) = sin(t) y 2 (t) = cos(t) 1 This is how the circular orbit is described in [ExM], but standard mathematical positive orientation is counterclockwise. fasshauer@iit.edu MATH 100 ITP 10

Let s try some other problems Space Orbits via Differential Equations Example The following should result in a spiral-shaped orbit: x (t) = x(t) + y(t), x(0) = 1 y (t) = x(t) y(t), y(0) = 1 Fill in the blanks (xxxxx) in the MATLAB code: myorbit = @(t,y) [xxxxx; xxxxx]; % f(t,y(t)) tspan = [0 10]; % range for t y0 = [xxxxx; xxxxx]; % starting point [t y] = ode23(myorbit,tspan,y0); plot(y(:,1),y(:,2), -o ) fasshauer@iit.edu MATH 100 ITP 11

Space Orbits via Differential Equations Example The following should result in an attracting circular orbit: x (t) = x(t) + y(t) x 3 (t) x(t)y 2 (t), x(0) = 2 y (t) = x(t) + y(t) x 2 (t)y(t) y 3 (t), y(0) = 0 Fill in the blanks (xxxxx) in the MATLAB code: myorbit = @(t,y) [xxxxx; xxxxx]; % f(t,y(t)) tspan = [0 10]; % range for t y0 = [xxxxx; xxxxx]; % starting point [t y] = ode23(myorbit,tspan,y0); plot(y(:,1),y(:,2), -o ) Try different starting points! fasshauer@iit.edu MATH 100 ITP 12

Space Orbits via Differential Equations The topics we have discussed up to now will come up in later MATH classes such as MATH 152 (Calculus II): polar coordinates, curves in parametric form MATH 251 (Multivariable Calculus): functions in vector form MATH 252 (Introduction to Differential Equations): (systems of) differential equations MATH 350 (Introduction to Computational Mathematics): numerical methods like ode23 fasshauer@iit.edu MATH 100 ITP 13

Approximating Derivatives Forward Differences Recall the definition of the derivative: y y(t + h) y(t) (t) = lim. h 0 h We can easily turn this into a numerical method by dropping the limit: y y(t + h) y(t) (t), h a so-called forward difference approximation. Example While this is in general only an approximation, it is exact for linear functions. Let y(t) = mt + b so that y (t) = m. Then y(t + h) y(t) h = [m(t + h) + b] [mt + b] h = mh h = m. fasshauer@iit.edu MATH 100 ITP 14

Circular Space Orbit Revisited Forward Differences We now construct our own method to follow the circular orbit (a simple differential equation solver). Remember the system of ODEs: x (t) = y(t) y (t) = x(t) Using the forward difference approximation we get x(t + h) x(t) = y(t) h x(t + h) = x(t) h y(t) y(t + h) y(t) = x(t) y(t + h) = y(t) + h x(t) h If we start at any point (x(t), y(t)), then we can get a new point (x(t + h), y(t + h)) near the orbit by using the above formulas with a small stepsize h. fasshauer@iit.edu MATH 100 ITP 15

Space War Orbit [ExM] x = 1; y = 0; % starting point h = 1/4; % small stepsize n = 2*pi/h; % to get one full revolution plot(x,y,. ) hold on for k = 1:n % compute new points near orbit x = x - h*y; y = y + h*x; plot(x,y,. ) end hold off axis([-1.1 1.1-1.1 1.1]) axis square This algorithm is known as Euler s method. Repeat with h = 1/32 and explain. fasshauer@iit.edu MATH 100 ITP 16

Important questions to be investigated in later classes: How accurate is Euler s method? series from MATH 152) ( MATH 350, uses Taylor Are there other more accurate or more efficient methods to solve ODEs? ( MATH 350) How does one solve differential equations analytically? ( MATH 152, MATH 252, MATH 461, MATH 488, MATH 489) Learn about other kinds of differential equations problems: we looked only at initial value problems there are also boundary value problems differential equations involving derivatives with respect to more than one independent variables become partial differential equations How sensitive are differential equations to their initial conditions? ( MATH 488, dynamical systems and chaos) fasshauer@iit.edu MATH 100 ITP 17

Second-order ODEs as Systems of First-order ODEs Consider the simple mathematical model for a falling body (see, e.g., [Gowers, Ch. 1]): x (t) = g integrate = x (t) = gt+v 0 integrate = x(t) = gt2 2 +v 0t+x 0. Let s pretend we can t integrate this equation, and use MATLAB instead. We need to convert this second-order ODE to a system of first-order ODEs (since that s all that MATLAB understands, and since this corresponds to standard form). If we introduce a second unknown function, v(t) = x (t), then we have x (t) = v(t) v (t) = g fasshauer@iit.edu MATH 100 ITP 18

Solving the Falling Rock Problem From the previous slide we know that the system x (t) = v(t) v (t) = g has solution x(t) = gt2 2 + v 0t + x 0, where x 0 and v 0 are the initial height and initial velocity, respectively. myrock = @(t,y) [y(2); -9.81]; % f(t,y(t)) tspan = [0 2]; % range for t y0 = [20; 0]; % starts at height 20, 0 velocity [t y] = ode23(myrock,tspan,y0); plot(t,y(:,1), -o ) % MATLAB s solution hold on % analytical solution from integration tt = linspace(0,2,100); plot(tt, -9.81*tt.^2/2 + y0(2)*tt + y0(1), r ) hold off fasshauer@iit.edu MATH 100 ITP 19

A Simple Spring-Mass Model Hooke s law states that F = kx, i.e., the force required to restore a spring from a displacement of x units out of equilibrium is proportional (with spring constant k) to the displacement. Since, from Newton s second law of motion, we also know that F = ma (mass acceleration), and a(t) = x (t), we get the following basic mathematical model for a spring-mass system 2 : x (t) = x(t). 2 For simplicity we set m = k = 1 fasshauer@iit.edu MATH 100 ITP 20

We actually can t solve x (t) = x(t). by simple integration, so we again use MATLAB (in MATH 252 you learn how to do this analytically as well). Introducing v(t) = x (t) as a second unknown function we get x (t) = v(t) v (t) = x(t) This looks suspiciously like our earlier orbit system! We have periodic motion, a so-called harmonic oscillator. fasshauer@iit.edu MATH 100 ITP 21

Solving the Spring Problem We might be able to guess that x (t) = x(t) can be satisfied by x(t) = cos(t), or by x(t) = sin(t). Again, the ODE by itself is not a well-posed problem. Additional initial conditions will give us a unique solution: myspring = @(t,y) [y(2); -y(1)]; % f(t,y(t)) tspan = [0 10]; % range for t y0 = [2; 0]; % initial displacement 2, velocity 0 [t y] = ode23(myspring,tspan,y0); plot(t,y(:,1), -o ) % MATLAB s solution fasshauer@iit.edu MATH 100 ITP 22

Let s try another problem Example If we add a damping term to the spring equations, then we get the so-called damped harmonic (van der Pol) oscillator: x (t) = µ(1 x(t) 2 )x (t) x(t), x(0) = 2, x (0) = 0. Convert to a first-order system: x (t) = v(t), x(0) = 2 v (t) = µ(1 x(t) 2 )v(t) x(t), v(0) = 0 Fill in the blanks (xxxxx) in the MATLAB code. Experiment with different values of µ = 0.01, 0.1, 1, 10, 100: mu = xxxxx; vanderpol = @(t,y) [xxxxx; xxxxx]; % f(t,y(t)) tspan = [0 1000]; % range for t y0 = [xxxxx; xxxxx]; % starting point [t y] = ode23(vanderpol,tspan,y0); plot(y(:,1),y(:,2), -o ) fasshauer@iit.edu MATH 100 ITP 23

Stiff ODEs Chapter 15 of Experiments with MATLAB Let s try another problem The van der Pol problem becomes very stiff for large values of the damping parameter µ. For such cases, there are special ODE solvers. Try ode23s instead of ode23 in those cases. More about the complicated phenomenon of stiffness is discussed in MATH 350 and MATH 478. fasshauer@iit.edu MATH 100 ITP 24

Connection to Matrices Let s try another problem Linear constant coefficient homogeneous ODEs (such as those we looked at above) can be written in matrix-vector form. Example The system y 1 (t) = y 2(t) y 2 (t) = y 1(t) is equivalent to [ y 0 1 (t) = 1 0 y 1 (t) = 0y 1(t) 1y 2 (t) y 2 (t) = 1y 1(t) + 0y 2 (t) ] y(t), where y(t) = [y 1 (t), y 2 (t)] T. To solve this system analytically we then need to find the eigenvalues and eigenvectors of the matrix ( MATH 252, MATH 332). fasshauer@iit.edu MATH 100 ITP 25

References I Appendix References T. A. Driscoll. Learning MATLAB. SIAM, Philadelphia, 2009. http://epubs.siam.org/ebooks/siam/other_titles_in_applied_ mathematics/ot115 Gowers, Timothy. Mathematics: A Very Short Introduction. Oxford University Press, 2002. D. J. Higham and N. J. Higham. MATLAB Guide (2nd ed.). SIAM, Philadelphia, 2005. http://epubs.siam.org/ebooks/siam/other_titles_in_applied_ mathematics/ot92 C. Moler. Numerical Computing with MATLAB. SIAM, Philadelphia, 2004. http://www.mathworks.com/moler/index_ncm.html fasshauer@iit.edu MATH 100 ITP 26

References II Appendix References C. Moler. Experiments with MATLAB. Free download at http://www.mathworks.com/moler/exm/chapters.html The MathWorks. MATLAB 7: Getting Started Guide. http://www.mathworks.com/access/helpdesk/help/pdf_doc/ matlab/getstart.pdf B. Coifman. Wave propagation on freeways. http://www2.ece.ohio-state.edu/~coifman/shock/ fasshauer@iit.edu MATH 100 ITP 27