Reading Chapter 12 of Higham’s Matlab Guide



Study Guide for Chapter 12 of Highams’s Matlab Guide text (updated 5-4-2010)

Higham’s text has the advantage (and disadvantage) that it packs lot of information in a few pages. This makes the book hard to read but it also presents information important in practical problems. My goal in selecting the two texts was to have a readable introduction (Attaway) and a text (Higham) that provides details of tools that are used in real applications.

Here is an overview of the importance of each example and topic in Chapter 12 of Higham.

Page 171 prior to 12.1:

• Discusses background on the stopping criteria for the algorithms and introduces the idea of using nested and anonymous functions to simplify passing parameters. This will be illustrated later.

Section 12.1. Quadrature

• pages 171through the top half of 174. Discusses numerical integration with quad and quadl using humps (and Fresnel integrals). Notes that the step size in the numerical integration is adaptively selected. The examples illustrate the use of anonymous functions. Files: quad_ex1.m, quad_ex2.m, quadl_ex1.m, quadl_ex2.m,

• On page 174 trapz, the trapezoid rule, is briefly mentioned. It is usually less accurate than quad or quadl.

• The bottom of page 174 illustrates double integration with dblquad. The example illustrates the use of function handles. Files: dblquad_ex.m

Section 12.2 Ordinary Differential Equations

• page 175, prior to 12.2.1 discusses the ode solvers in general

• 12.2.1, pages 175 to the top of page 177 illustrate the use of ode45 with an example whose solution is exp(-t) .* cos(5t) . Notes that the step size in the solver is adaptively selected. If tspan is a vector with more than two components the solution is returned at the times in tspan. Files: ode45_ex1.m Associated examples: runge_kutta_hand_examples.m, runge_kutta_fehlberg_hand_example.pdf

• Middle of page 177, quiver is used to illustrate plotting of a vector field. We noted in class that the simplest numerical method, Euler’s method, constructs a solution to the ode by “following the tangent” lines pictured, for example, in the vector field plot. Files: ode45_vector_field.m

• Bottom of page 177 through page 178. The pendulum example illustrates how a higher order equation (second order here) can be written as a first order system and then be solved with ode45. Quiver is again illustrated to construct a vector field in the phase plane plot. A phase plane plot pictures y1(t) versus y2(t) rather than y versus time, t . Running ode45 with a variety of different initial conditions is illustrated. Files: pendulum_phase_ex.m Associated examples and material: conversion.pdf.

• Page 179 – 182. The Rossler example is presented. Prior to presenting the example the use of options and odeset is discussed to set the approximate accuracy in the ode solver. The use of anonymous or nested functions are mentioned as the best way to change parameters in and ode solution. The use of options and passing parameters is illustrated in rossler_ex1. Rossler_ex0 illustrates an older approach that is now not recommended. The rossler examples also illustrate plot3 and subplot. Rossler_ex2 illustrates the ability of ode45 to return a structure containing information about the solution. Fields of the structure (let us call it sol) include the t (sol.x) and y values (sol.y) as well at stats about the solution (sol.stats). Note that deval can be used with sol to calculate the solution at any user specified set of t values. Files: rossler_ex1.m, rossler_ex0.m, rossler_ex2.m

• Section 12.2.2, pages 183-186. The fox – rabbit problem is used to illustrate how an ode solver can identify an event during the computation. Files: fox0.m, fox1.m, fox1b.m, fox_rabbit.m

• Section 12.2.3, bottom of page184, pages 187-189. A stiff ode from chemistry is presented. It is noted that an explicit solver such as ode45 can be used to solve such problems but usually require a huge number of steps. An implicit or stiff solver such as ode15s requires only a modest number of steps at the expense of more work per step. Implicit solvers require solving a nonlinear equation at each step. However for a stiff problem like the chem problem, ode15s will be faster than ode45. The use of odeset to set stats on is illustrated in this example. Note that stiff problems typically have time constants of different scales (a quickly and a slowly changing portion of the solution). Files: chem0.m chem0b.m, chem..m Associated examples: euler_and_backwards_hand_and_computer_example.pdf

• Bottom of page 189- top of page 190. A table of the possible choices for ode solvers is listed and it is noted that one should initially try ode45 and if the problem seems to be stiff one should try ode15s.

• Page 190-middle of page 191 and page 192. The rcd (reaction-convection-diffusion) example illustrates how a Jacobian can be coded to speed up the calculation in a stiff solver. At each step of the ode solution a stiff solver solves a nonlinear system of equations using Newton’s method (Newton’s method is discussed in Calculus 1). The Jacobian is needed in Newton’s method. If code for the Jacobian is not available then it is estimated using finite differences. The rcd example also illustrates how one can approximately solve a partial differential equation (PDE) with an ode solver (the technique is called the method of lines) and also illustrates a PDE which models convection, diffusion and a (chemical) reaction. Finally a waterfall plot is illustrated. Files: rcd.m, rcd1.mff Associated examples: jacobian_used_to_solve_systems_hand_example.pdf, calculating_jacobian_hand_example.pdf

• Page 191 and the middle of page 193. A differential algebraic system (DAE) is illustrated. In the equation M dy/ dt = f(y(t)) on the bottom of page 191 the last row of M has only zeros. Therefore the last equation in the matrix equation M dy/ dt = f(y(t)) has no derivative term. Therefore this last equation is only an algebraic equation and the entire system is called a differential – algebraic system. The Matlab routines ode15s and ode23t can solve such DAE systems. Chemakzo illustrates this and illustrates how odeset can be used to include a mass matrix in the ode solver. Files: chemakzo.m

• Middle of page 193. Notes that ode15i can be used to handle more general DAE’s (defined implicitly). Few details are supplied.

• Bottom of page 193 and top of 195. It is noted that more examples can be obtained in Matlab’s odeexamples function.

Section 12.3 Boundary Value Problems

• Page 195 to top of page 198. Boundary value problems are introduced and the solution with bvp4c is illustrated with the equation describing the shape of a water droplet. Also the choice of color in the fill command is illustrated. Files: droplet.m

• Page 198. An example for liquid crystal theory further illustrates the use of bvp4c. The continuation idea is illustrated to get suitable initial conditions. The basic continuation idea is that you use the solution to one boundary value problem to get the initial condition to another boundary value problem. Also note the use of a nested function to pass a parameter. Files: lcrun.m

• Bottom of pages 198, 200-201. The model of a skipping rope illustrates how bvp4c can solve a boundary value problem that contains unknown parameters. When there is an unknown parameter extra boundary conditions are required in order to identify the parameter. Files: skiprun.m, skiprun1.m skiprun2.m

• Bottom of page 201 to page 202. Discusses sources of additional help and information for bvp4c.

Section 12.4 Delay-Differential Equations

• Bottom of page 202- page 204. The idea of delay differential equations is discussed and the function dde23 is illustrated with a predator-prey problem in function harvest. Files: harvest

• Pages 205 to top of 207. The second example models two interacting neurons. The use of a history function to specify the initial conditions is illustrated. Also this example has more than one delay. Files: neural.m

• Page 205 also mentions sources of additional help and information for dde23.

Section 12.5 Partial Differential Equations.

• Pages 205, 207 and top of 208. pdepe is discussed including the types of partial differential equation that can be solved with pdepe.

• Page 208 – top of page 210. The Black-Scholes equation from financial mathematics is used to illustrate pdepe. Functions defining the PDE, defining the initial conditions and defining the boundary conditions are illustrated. Files: bs.m

• Page 210-212. A reaction diffusion equation from mathematical biology is used to illustrate pdepe. The example is a system of two partial differential equations. Files: mbiol.m

• Page 211. Notes that in addition to pdepe there is a partial differential equation toolbox that can solve more complicated partial differential equations. Pdepe is restricted to PDE whose boundary conditions are at fixed locations in x (at x = a and x = b, where a and b are constants) and whose initial conditions are at a fixed time (t = t0). The PDE toolbox can solve problems whose boundaries are more general.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download