Maple Tools for Differential Equations A. J. Meir

Similar documents
Math Linear Differential Equations

Physics 235 Chapter 2. Chapter 2 Newtonian Mechanics Single Particle

dy dx = xey (a) y(0) = 2 (b) y(1) = 2.5 SOLUTION: See next page

EXERCISES FOR SECTION 1.5

Simulation-Solving Dynamic Models ABE 5646 Week 2, Spring 2010

Math 334 Test 1 KEY Spring 2010 Section: 001. Instructor: Scott Glasgow Dates: May 10 and 11.

Chapter 7: Solving Trig Equations

!!"#"$%&#'()!"#&'(*%)+,&',-)./0)1-*23)

Chapter 2. First Order Scalar Equations

Morning Time: 1 hour 30 minutes Additional materials (enclosed):

Announcements: Warm-up Exercise:

Two Coupled Oscillators / Normal Modes

Single and Double Pendulum Models

KEY. Math 334 Midterm III Winter 2008 section 002 Instructor: Scott Glasgow

Some Basic Information about M-S-D Systems

23.2. Representing Periodic Functions by Fourier Series. Introduction. Prerequisites. Learning Outcomes

The equation to any straight line can be expressed in the form:

MATH 128A, SUMMER 2009, FINAL EXAM SOLUTION

Chapter 6. Systems of First Order Linear Differential Equations

Final Spring 2007

KEY. Math 334 Midterm III Fall 2008 sections 001 and 003 Instructor: Scott Glasgow

15. Vector Valued Functions

EE 301 Lab 2 Convolution

2.7. Some common engineering functions. Introduction. Prerequisites. Learning Outcomes

Vehicle Arrival Models : Headway

SOLUTIONS TO ECE 3084

In this chapter the model of free motion under gravity is extended to objects projected at an angle. When you have completed it, you should

2. Nonlinear Conservation Law Equations

Section 3.5 Nonhomogeneous Equations; Method of Undetermined Coefficients

KEY. Math 334 Midterm I Fall 2008 sections 001 and 003 Instructor: Scott Glasgow

dt = C exp (3 ln t 4 ). t 4 W = C exp ( ln(4 t) 3) = C(4 t) 3.

ODEs II, Lecture 1: Homogeneous Linear Systems - I. Mike Raugh 1. March 8, 2004

SMT 2014 Calculus Test Solutions February 15, 2014 = 3 5 = 15.

Ordinary dierential equations

Predator - Prey Model Trajectories and the nonlinear conservation law

Differential Equations

Hamilton- J acobi Equation: Explicit Formulas In this lecture we try to apply the method of characteristics to the Hamilton-Jacobi equation: u t

Chapter 3 Boundary Value Problem

u(x) = e x 2 y + 2 ) Integrate and solve for x (1 + x)y + y = cos x Answer: Divide both sides by 1 + x and solve for y. y = x y + cos x

Matlab and Python programming: how to get started

Math 23 Spring Differential Equations. Final Exam Due Date: Tuesday, June 6, 5pm

Mathcad Lecture #8 In-class Worksheet Curve Fitting and Interpolation

Challenge Problems. DIS 203 and 210. March 6, (e 2) k. k(k + 2). k=1. f(x) = k(k + 2) = 1 x k

Lecture 2-1 Kinematics in One Dimension Displacement, Velocity and Acceleration Everything in the world is moving. Nothing stays still.

Problem Set 5. Graduate Macro II, Spring 2017 The University of Notre Dame Professor Sims

Econ107 Applied Econometrics Topic 7: Multicollinearity (Studenmund, Chapter 8)

Solutions from Chapter 9.1 and 9.2

Bias in Conditional and Unconditional Fixed Effects Logit Estimation: a Correction * Tom Coupé

MEI STRUCTURED MATHEMATICS 4758

Math 333 Problem Set #2 Solution 14 February 2003

Class Meeting # 10: Introduction to the Wave Equation

Introduction to Probability and Statistics Slides 4 Chapter 4

This document was generated at 1:04 PM, 09/10/13 Copyright 2013 Richard T. Woodward. 4. End points and transversality conditions AGEC

5.2. The Natural Logarithm. Solution

d 1 = c 1 b 2 - b 1 c 2 d 2 = c 1 b 3 - b 1 c 3

Finish reading Chapter 2 of Spivak, rereading earlier sections as necessary. handout and fill in some missing details!

6.2 Transforms of Derivatives and Integrals.

Math 2142 Exam 1 Review Problems. x 2 + f (0) 3! for the 3rd Taylor polynomial at x = 0. To calculate the various quantities:

HOMEWORK # 2: MATH 211, SPRING Note: This is the last solution set where I will describe the MATLAB I used to make my pictures.

MATH 4330/5330, Fourier Analysis Section 6, Proof of Fourier s Theorem for Pointwise Convergence

THE 2-BODY PROBLEM. FIGURE 1. A pair of ellipses sharing a common focus. (c,b) c+a ROBERT J. VANDERBEI

SUPPLEMENTARY INFORMATION

4.5 Constant Acceleration

t is a basis for the solution space to this system, then the matrix having these solutions as columns, t x 1 t, x 2 t,... x n t x 2 t...

Solutions to Assignment 1

Fishing limits and the Logistic Equation. 1

A First Course on Kinetics and Reaction Engineering. Class 19 on Unit 18

This document was generated at 7:34 PM, 07/27/09 Copyright 2009 Richard T. Woodward

Lab #2: Kinematics in 1-Dimension

KINEMATICS IN ONE DIMENSION

Online Appendix to Solution Methods for Models with Rare Disasters

( ) a system of differential equations with continuous parametrization ( T = R + These look like, respectively:

Let us start with a two dimensional case. We consider a vector ( x,

Math Wednesday March 3, , 4.3: First order systems of Differential Equations Why you should expect existence and uniqueness for the IVP

R t. C t P t. + u t. C t = αp t + βr t + v t. + β + w t

The Asymptotic Behavior of Nonoscillatory Solutions of Some Nonlinear Dynamic Equations on Time Scales

Chapter Floating Point Representation

MA 214 Calculus IV (Spring 2016) Section 2. Homework Assignment 1 Solutions

Physics 127b: Statistical Mechanics. Fokker-Planck Equation. Time Evolution

System of Linear Differential Equations

Chapter #1 EEE8013 EEE3001. Linear Controller Design and State Space Analysis

= ( ) ) or a system of differential equations with continuous parametrization (T = R

Decimal moved after first digit = 4.6 x Decimal moves five places left SCIENTIFIC > POSITIONAL. a) g) 5.31 x b) 0.

5.1 - Logarithms and Their Properties

Y 0.4Y 0.45Y Y to a proper ARMA specification.

Echocardiography Project and Finite Fourier Series

Constant Acceleration

Guest Lectures for Dr. MacFarlane s EE3350 Part Deux

t 2 B F x,t n dsdt t u x,t dxdt

Module 2 F c i k c s la l w a s o s f dif di fusi s o i n

Week 1 Lecture 2 Problems 2, 5. What if something oscillates with no obvious spring? What is ω? (problem set problem)

Circuit Variables. AP 1.1 Use a product of ratios to convert two-thirds the speed of light from meters per second to miles per second: 1 ft 12 in

Module 3: The Damped Oscillator-II Lecture 3: The Damped Oscillator-II

Summary of shear rate kinematics (part 1)

1 Differential Equation Investigations using Customizable

1. An introduction to dynamic optimization -- Optimal Control and Dynamic Programming AGEC

DIFFERENTIAL GEOMETRY HW 5

1 1 + x 2 dx. tan 1 (2) = ] ] x 3. Solution: Recall that the given integral is improper because. x 3. 1 x 3. dx = lim dx.

arxiv: v1 [math.ca] 15 Nov 2016

( ) ( ) if t = t. It must satisfy the identity. So, bulkiness of the unit impulse (hyper)function is equal to 1. The defining characteristic is

Transcription:

Maple Tools for Differenial Equaions A. J. Meir Copyrigh (C) A. J. Meir. All righs reserved. This workshee is for educaional use only. No par of his publicaion may be reproduced or ransmied for profi in any form or by any means, elecronic or mechanical, including phoocopy, recording, or any informaion sorage and rerieval sysem wihou prior wrien permission from he auhor. No for profi disribuion of he sofware is allowed wihou prior wrien permission, providing ha he workshee is no modified in any way and full credi o he auhor is acknowledged. (This documen is largely based on a similar documen originally wrien by P. G. Schmid.) Maple will find symbolic soluions (ha is, closed-form soluions or soluion formulas) for many ypes of d.e.s and i.v.p.s, including separable and linear firs-order equaions. Moreover, Maple can compue and graph numerical soluions (ha is, approximae soluions) for virually all i.v.p.s of pracical ineres. 1. Finding and Ploing Symbolic Soluions. To find a general soluion for a given d.e., use Maple's dsolve command, whose general forma is dsolve(de,unknown_funcion). The following command, for example, finds a general soluion for he d.e. x' = Kk x (he radioacivedecay equaion), where he unknown funcion is x = x and k is a parameer: dsolve(d(x)()=-k*,); x = _C1 e Kk (1) Noe ha inside he dsolve command he derivaive, x', should be wrien as D x and ha he independen variable,, mus be carried along (so ha he d.e. becomes D x = Kk x insead of x' = Kk x ). In Maple's response, _C1 denoes an arbirary consan. (In general, Maple renders arbirary consans as _C1, _C, _C3, and so forh.) In sandard calculus noaion, we would wrie he soluion formula as x = c e Kk. The nex command produces a general soluion for he d.e. x'' + a x = 0 (he elasic-spring equaion wih a = k ), where he unknown funcion is again x = x and a is a parameer: m dsolve(d(d(x))()+a^*,); x = _C1 sin a C_C cos a () Noe ha he second derivaive, x'', should be wrien as D D x and ha he independen variable mus be carried along, jus as in he previous example. Wih a minor modificaion, we can use he dsolve command o find symbolic soluions of i.v.p.s; he modified forma is dsolve({de,iniial_condiion(s)},unknown_funcion). Noe he "curly braces" around he d.e. and iniial condiion(s). For example, le's solve he firs-order i. v.p. x' = Kk x, x 0 = x0 : dsolve({d(x)()=-k*,x(0)=x0},); x = x0 e Kk (3) Nex, we solve he second-order i.v.p. x'' + a x = 0, x 0 = x0, x'(0) = v0 : 1

dsolve({d(d(x))()+a^*=0,x(0)=x0,d(x)(0)=v0},); v0 sin a x = Cx0 cos a a () In order o plo a soluion generaed by he dsolve command, we firs have o give i a name, say, s. The following command ses s equal o he righ-hand side of he immediaely preceding soluion formula: s:=rhs(%); s := v0 sin a a Cx0 cos a (5) Noe: The percen (%) is jus a placeholder for he las oupu generaed before execuion of he presen command (which, in his case, happens o be he soluion formula produced by he preceding dsolve command). Insead of using he percen, we could have given a name (say, sol ) o he soluion formula and used ha name in he rhs command: sol:=dsolve({d(d(x))()+a^*=0,x(0)=x0,d(x)(0)=v0},); v0 sin a sol := x = Cx0 cos a a (6) s:=rhs(sol); s := v0 sin a a Cx0 cos a (7) If we now specify he value of he parameer a and he iniial values x0 and v0, we can plo s jus like any oher funcion. Se, for example, a = 1, x0 =, and v0 = K3 : a:=1; x0:=; v0:=-3; a := 1 x0 := v0 := K3 (8) In his case, he soluion of he i.v.p. is s; K3 sin C cos (9) and a graph can be generaed wih he usual plo command: plo(s,=-10..0);

3 1 K10 0 10 0 K1 K K3 To obain he soluion and is graph for oher values of he parameer a or oher iniial values x0 and v0, jus re-execue he las hree commands, changing only he firs one as needed. For furher deails on ploing, especially on simulaneous ploing of several graphs, see he handou "More on Basic Maple Commands".. Ploing Direcion Fields and Numerical Soluions. The basic Maple command for he graphical represenaion of direcion fields and approximae soluion curves is DEplo ; i is par of a package of rouines called DEools, which mus be explicily loaded wih he command wih(deools): To plo a direcion field for a firs-order d.e. of he form x' = f, x, in he recangle = a..b, x = c..d, use he DEplo command in he form DEplo(D(x)()=f(,),,=a..b,x=c..d). The following command, for example, generaes a direcion field for x' = x in he recangle = K3..3, x =..6 : DEplo(D(x)()=^,,=-3..3,x=-6..6); 3

6 K3 K K1 0 1 3 K K The defaul number of grid poins used is 0 in eiher coordinae direcion. You can change ha, if needed, by adding he opion dirgrid=[m,n] inside he DEplo command, where m and n denoe he desired number of grid poins in he horizonal and verical direcion, respecively. Example: DEplo(D(x)()=^,,=-3..3,x=-6..6,dirgrid=[15,30]);

6 K3 K K1 0 1 3 K K In addiion o a direcion field, Maple will compue and display one or more approximae soluion curves of a given d.e. if suiable iniial condiions are specified in he form {[x(0)=x0],[x(1)=x1],[x()=x],...}, immediaely following he range specificaions in he DEplo command. Noe ha he se of iniial condiions is enclosed in curly braces, while each individual condiion appears in brackes. Boh, brackes and braces, mus be presen even if only a single iniial condiion is given. For example, he following command produces a direcion field for x' = x, as before, along wih he (approximae) graph of a paricular soluion, saisfying he iniial condiion x 0 =1 : DEplo(D(x)()=^,,=-3..3,x=-6..6,{[x(0)=1]}); 5

6 K3 K K1 0 1 3 K K Now we will add a second soluion curve, saisfying he iniial condiion x 0 = K1 : DEplo(D(x)()=^,,=-3..3,x=-6..6,{[x(0)=1],[x(0)=-1]}) ; 6 K3 K K1 0 1 3 K K 6

In general, he given iniial poins do no have o lie inside he plo window. If iniial condiions are given, specificaion of he verical range (x-range) is opional; if omied, DEplo will choose he x-range auomaically, depending on where he soluion curves "go". This is someimes useful, bu no always. Le's ry i wih he above example (same command as before, bu wihou x-range specificaion): DEplo(D(x)()=^,,=-3..3,x=-6..6,{[x(0)=1],[x(0)=-1]}) ; 6 K3 K K1 0 1 3 K K Can you explain he poor oucome? (Hin: The exac soluion wih iniial condiion x 0 = 1 has a verical asympoe a = 1.) If only he soluion curves are of ineres, display of he direcion field arrows can be suppressed by adding he opion arrows=none inside he DEplo command, following he specificaion of iniial condiions. Example: DEplo(D(x)()=^,,=-3..3,x=-6..6,{[x(0)=1],[x(0)=-1]}, arrows=none); 7

6 K3 K K1 0 1 3 K K Many furher opions are available. In fac, mos of he opions available wih he basic plo command will also work wih DEplo. Very useful for prining purposes is he opion linecolor=black, which causes he soluion curves o be drawn in black raher han yellow (he defaul, which looks piiful on a black-and-whie prinou). The color and appearance of he direcion field arrows can be cusomized, oo, bu his will hardly ever be necessary. For deails, consul he relevan help pages (by yping?deplo or?plo,opions). Noe: pions may be added o he DEplo command in any order, bu mus be preceded by he range specificaion(s) and iniial condiion(s) (if any). Example: DEplo(D(x)()=^,,=-3..3,x=-6..6,{[x(0)=1],[x(0)=-1]}, dirgrid=[10,10],linecolor=black,color=green,ile=`dx/d=x^`); 8

dx/d=x^ 6 K3 K K1 0 1 3 K K The defaul mehod ha DEplo uses o compue approximae soluions of he given d.e. is "rk", a socalled h order Runge-Kua mehod, much more sophisicaed han he classical Euler mehod. You can force Maple o use he Euler mehod by specifying he opion mehod=classical. Boh "rk" and "Euler" employ a fixed sepsize; he defaul sepsize is (b Ka)/0, where a..b is he horizonal range (-range) of he plo. Frequenly, i will be necessary o reduce he sepsize, for improved numerical accuracy. This can be done by specifying he opion sepsize=h, where h denoes he desired sepsize, smaller han (b Ka)/0. Le's ry he following example, where we approximae he same soluions of x' = x as before, bu wih a larger verical range (K10..10) and using he classical Euler mehod (insead of "rk"): DEplo(D(x)()=^,,=-3..3,x=-9..9,{[x(0)=1],[x(0)=-1]}, mehod=classical,linecolor=black); 9

8 6 K3 K K1 0 1 3 K K K8 The horizonal par of he lower soluion curve is clearly erroneous -- i cerainly doesn' mach he direcion field! The (defaul) sepsize used in he plo is.3 (namely, (b Ka)/0 wih b = 3 and a = K3 ), and apparenly his is no accurae enough. Reducing he sepsize should remedy he problem: DEplo(D(x)()=^,,=-3..3,x=-9..9,{[x(0)=1],[x(0)=-1]}, mehod=classical,sepsize=.1,linecolor=black); 10

8 6 K3 K K1 0 1 3 K K K8 To accuraely rack a rapidly growing or highly oscillaory soluion, i may be necessary o employ a very small sepsize and compue millions of daa poins. No only will his consume a lo of ime -- soring millions of daa poins may also ax Maple's memory. Forunaely, i is no nessary o sore all he compued daa poins (he number of poins used in creaing he plo is anyway limied by he resoluion of compuer screen and laser priner). Wih he opion ieraions=n, you can insruc Maple o sore and plo only every nh of he compued daa poins. This opion, if applied judiciously, can save a lo of ime and memory, wih no loss of numerical accuracy. As a drasic example, we will compue and display an approximae soluion of he i.v.p. dx =1Ke x, x 0 =0, d on he inerval = 0..15, using "rk" (he defaul mehod) wih a sepsize of.001 and 100 ieraions beween ploed poins. (Thus, Maple will compue 15,000 daa poins, bu sore and plo only 150.) DEplo(D(x)()=1-exp()*^,,=0..15,{[x(0)=0]}, sepsize=.001,ieraions=100,arrows=none,linecolor=black); 11

0.6 0.5 0. 0.3 0. 0.1 0 0 5 10 15 Generaing his plo sill akes quie some ime, bu wihou he opion ieraions=100, i would ake abou en imes as long, wihou any visible improvemen! n he oher hand, if you ried o speed hings up by using a sepsize significanly greaer han.001, he plo would no be reliable. Check i ou! Beyond "rk" (he defaul mehod) and "Euler" ( mehod=classical ), you have a choice of several, much more sophisicaed d.e. solvers. ne of hem is "rkf5", a so-called h/5h order Runge-Kua-Fehlberg mehod, which can be invoked by specifying mehod=rkf5 in he DEplo command. While "rk" and "Euler" use a fixed sepsize, "rkf5" employs a variable sepsize ha's auomaically adjused in accordance wih he "siffness" of he problem. As an adapive (self-correcing) mehod, "rkf5" is more reliable han "rk" or "Euler", bu usually slower. Bu in "siff" problems (like he previous example), "rkf5" offers a double advanage: You don' have o worry abou he sepsize, and i is faser han "rk" or "Euler"! (In general, conrolling and adjusing he sepsize as needed is more efficien han using a very small sepsize hroughou.) Since "rkf5" conrols he (numerical) sepsize auomaically, specifying a sepsize when using his mehod has no effec on he numerical accuracy of he procedure; i does, however, affec he number of poins ploed and, hereby, he apparen smoohness of he graph. More precisely, in conjuncion wih "rkf5", he specified sepsize becomes simply he horizonal disance beween consecuive poins ploed. For example, if we solve he previous problem wih "rkf5", we should specify a sepsize of.1 o obain he same number of poins ploed as before, when we used "rk" wih a (numerical) sepsize of.001 and 100 ieraions beween poins ploed. Le's ry i: DEplo(D(x)()=1-exp()*^,,=0..15,{[x(0)=0]}, mehod=rkf5,sepsize=.1,arrows=none,linecolor=black); 1

0.6 0.5 0. 0.3 0. 0.1 0 0 5 10 15 DEplo will no only solve firs-order, bu also higher-order i.v.p.s (alhough no direcion fields can be generaed for he laer). The following command, for example, produces an approximae soluion of he i.v.p. x'' + x = 0, x 0 =, x'(0) = -3, whose symbolic soluion is cos K3 sin : DEplo(D(D(x))()+=0,,=-10..0,{[x(0)=,D(x)(0)=-3]}, sepsize=.,linecolor=black); 13

3 1 K10 0 10 0 K1 K K3 Noe ha he wo iniial condiions appear inside a single pair of brackes (because hey deermine only one soluion curve). The sepsize specificaion was necessary, due o he oscillaory naure of he graph and he lengh of he plo inerval; he defaul sepsize would have been 30/0 = 1.5! (Check ou wha you would ge wihou sepsize specificaion.) Basically, you have he same opions as in he firs-order case (excep for hose relaing o direcion fields, of course), and jus as in he firs-order case, several approximae soluions can be generaed simulaneously, by specifying several ses of iniial daa in he form {[x(0)=x0,d(x)(0)=v0],[x(1)=x1,d(x)(1)=v1],[x(3)=x3,d(x)(3)=v3],...}. Noe ha, in analogy o he firs-order case, he enire se of iniial condiions is enclosed in curly braces, while he iniial condiions for each individual soluion curve appear in brackes. Example: DEplo(D(D(x))()+=0,,=-10..0,{[x(0)=,D(x)(0)=-3],[x (0)=-3,D(x)(0)=]},linecolor=black); 1

3 1 K10 0 10 0 K1 K K3 Prey lousy! bviously, we should reduce he sepsize or use a more flexible solver. Le's do boh and also add some perks: DEplo(D(D(x))()+=0,,=-10..0,{[x(0)=,D(x)(0)=-3],[x (0)=-3,D(x)(0)=]}, mehod=rkf5,sepsize=.,linecolor=[blue,green], ile=`x(0)=, x'(0)=-3 (blue); x(0)=-3, x'(0)= (green)`, ilefon=[times,rman,1]); 15

x(0)=, x'(0)=-3 (blue); x(0)=-3, x'(0)= (green) 3 1 K10 0 10 0 K1 K K3 16