A Automatic reformulation of ODEs to systems of first order equations

Size: px
Start display at page:

Download "A Automatic reformulation of ODEs to systems of first order equations"

Transcription

1 A Automatic reformulation of ODEs to systems of first order equations Á. BIRKISSON, University of Oxford Most numerical ODE solvers require problems to be written as systems of first order erential equations. This normally requires the user to rewrite higher order erential equations as coupled first order systems. Here, we introduce the treevar class, written in object-oriented Matlab, which is capable of algorithmically reformulating higher order ODEs to equivalent systems of first order equations. This allows users to specify problems using a more natural syntax, and saves them from having to manually derive the first order reformulation. The technique works by using operator overloading to build up syntax trees of expressions as mathematical programs are evaluated. It then applies a set of rules to the resulting trees to obtain the first order reformulation, which is returned as another program. This technique has connections with operator overloaded algorithmic/automatic erentiation. We present how treevar has been incorporated in Chebfun, greatly improving the ODE capabilities of the system. CCS Concepts: Computing methodologies Representation of mathematical functions; Mathematics of computing Mathematical software; Differential equations; Automatic erentiation; General Terms: Algorithms, Design Additional Key Words and Phrases: Analysis of mathematical functions, automatic erentiation, automatic reformulation, initial value problems, object-oriented programming, operator overloading, ordinary erential equations, syntax trees 1. INTRODUCTION Every day, thousands of mathematicians, scientists and engineers use numerical solvers to solve initial-value problems (IVPs) of ordinary erential equations (ODEs). Compared with boundary-value problems (BVPs), where conditions are imposed on the solution at both endpoints of the space or time interval, IVPs have a special structure. This special structure is that all information passes in one direction over the interval, from the initial time t = t 0 to the final time t = t f. The standard way to take advantage of this local structure of IVPs is to use tepping methods, such as Runge-Kutta or Adams-Bashforth formulas [Stoer and Bulirsch 2002]. Most numerical solvers based on such formulas only accept first order erential equations, that is, problems on the form y = f(t, y), t 0 t t f, (1) with given initial value(s) y(t 0 ) = y 0. Therefore, solving higher order erential equations requires writing them as an equivalent system of first order erential equations. This is for example the case with all the ODE solvers in Matlab, such as ode45 (a Runge-Kutta method) and ode113 (an Adams-Bashforth method) [Shampine and Reichelt 1997]. This work is supported by The MathWorks, Inc. and by the European Research Council under the European Union s Seventh Framework Programme (FP7/ )/ERC grant agreement Author s addresses: Mathematical Institute, University of Oxford, Andrew Wiles Building, Woodstock Road, Oxford, England OX2 6GG. birkisson@maths.ox.ac.uk. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org. YYYY ACM /YYYY/01-ARTA $15.00 DOI:

2 A:2 Ásgeir Birkisson Even in the case of boundary-value problems for ordinary erential equations, many numerical solvers also require problems to be written on a standard form similar to (1), namely y = f(t, y), a t b, (2) g(y(a), y(b)) = 0. (3) In [Ascher and Russell 1981], Ascher and Russell list techniques for how various types of BVPs, such as those with nonseparated boundary conditions, problems with conditions imposed at an unknown boundary point and problems with integral terms can be converted to the standard form before being passed to numerical solvers. While it is possible to rewrite any ODE as a system of first order erential equations, this usually requires the user to do so manually. Additionally, it is not aesthetically attractive. As an example, consider the well known van der Pol oscillator, which originally arose in the study of nonlinear electrical circuits [van der Pol 1926; Strogatz 1994]. The van der Pol oscillator is affected by nonlinear damping, and is governed by the second order erential equation u + µ(u 2 1)u + u = 0, u(t 0 ) = u 0, u (t 0 ) = u 0. (4) Here, u = u(t) and µ 0 is a scalar parameter that controls the strength of the damping. It feels more natural to solve the problem numerically as the second order ODE (4), rather than as its first order reformulation, u 1 = u 2, u 2 = µ(1 u 2 1)u 2 u 1, u 1 (t 0 ) = u 0, u 2 (t 0 ) = u 0. Here, we introduce the treevar class (or simply treevar), written in object-oriented Matlab. It enables automatic conversion of ODEs posed as higher order equations, such as (4), to systems of first order equations, such as (5). This allows users to pose problems in their natural form; they can then be solved using standard ODE solvers after the reformulation. The technique works by applying operator overloading to build up syntax trees of mathematical expressions as functions are evaluated. It then analyses the resulting trees and applies a set of rules to them to obtain the first order reformulation. treevar works for both scalar and coupled quasilinear erential equations. This paper is structured as follows. In Section 2, we describe the implementation of treevar and list the algorithms it employs for carrying out the first order reformulation. The technique applied by treevar is related to operator overloaded algorithmic/automatic erentiation, which obtains derivatives of mathematical functions by injecting statements into the evaluation trace of a program, defined in Section 2. In Section 3, we give examples on how the automatic reformulation of ODEs can be used to solve problems with the solvers readily available in Matlab. In Section 4, we discuss how treevar has been incorporated in Chebfun [Driscoll et al. 2014], greatly improving its IVP capabilities by enabling the system to avoid using global methods (as opposed to time-stepping methods) for solving IVPs. Finally, we list our conclusions and potential further avenues of investigation in Section 5. The presentation in this paper is based on Version 1.0 of treevar, available on GitHub [Birkisson 2016]. treevar was introduced in Version 5.1 of Chebfun (with some tweaks for Chebfun specific applications) Alternatives to a first order reformulation Before continuing, we mention that there exist numerical methods for solving ODEs that don t require problems to be written on their first order form. These are particu- (5)

3 AUTOMATIC REFORMULATION OF ODES A:3 larly important for erential equations on the form y = f(t, y), that is, where the right-hand side does not depend on y. Such problems often arise in celestial mechanics. Two classes of methods especially fit for such problems are often referred to as Nyström and Störmer methods [Hairer et al. 2008]. The simplest type of a Störmer method, where for a tep size t, the solution at the n + 1st tep is computed via y n+1 = y n 1 + 2y n + ( t) 2 f(t n, y n ), was applied in [Verlet 1967] for integrating the equation of motion of a system of particles interacting through a Lennard-Jones potential. Subsequently, in the field of molecular dynamics, the method became known as Verlet integration. 2. THE TREEVAR CLASS AND CONVERSION OF ODES TO FIRST ORDER SYSTEMS 2.1. The evaluation trace and AD background In various applications in scientific computing, derivatives play a central role. Given a function f(x), the two best known methods for computing derivatives are finite erence schemes and symbolic erentiation. Both these methods suffer from drawbacks; finite erence schemes suffer both from round-off errors and truncation errors (which usually dominate the round-off errors), while symbolic erentiation can experience a combinatorial explosion of computation time and memory requirements [Griewank and Walther 2008; Neidinger 2010]. Automatic, or algorithmic, erentiation (AD) aims to introduce techniques to compute accurate derivatives in a fast way. The derivatives only suffer from round-off errors from the evaluation of functions, not truncation errors. Like finite erence schemes, AD works entirely at the numerical level. However, AD uses information about the functions it is erentiating to avoid truncation errors. A key concept in AD is that of the evaluation trace. The evaluation trace is essentially a sequence of elementary calculations taken to evaluate a program with input variables u 1,..., u n, to obtain output variables y 1,..., y m. In the mathematical context, a program often means a function or an operator. The evaluation trace is defined by Griewank and Walther as follows: An evaluation trace is basically a record of a particular run of a particular program, with particular specified values for the input variables, showing the sequence of floating point values calculated by a (slightly idealized) processor and the operators that computed them. [Griewank and Walther 2008, p. 4] Each part of the sequence is associated with what is known in the AD literature as an intermediate variable. The final output of the program is obtained by performing series of computations, using elementary operators such as cos, log, +,, with the intermediate variables. All the elementary operators are assumed to be either unary or binary. At the start of a computation, we initialise the intermediate variables v k, for k 0, to be the input variables to the program. We denote the kth elementary operator in the sequence by ϕ k, and its result by the intermediate variable v k, for k > 0. For example, if ϕ k is a binary operator, we have v k = ϕ k (v i, v j ), where v i and v j are intermediate variables, with i, j < k. As an example of an evaluation trace, let y be the function of two variables given by the formula y = (u 1 + u 2 ) sin(u 2 2) + 4(u 1 + u 2 2). (6)

4 A:4 Ásgeir Birkisson Assignment Value of v k v 1 = u v 0 = u v 1 = v 1 + v = v 2 = v = v 3 = sin(v 2 ) sin(0.2500) = v 4 = v 1 v = v 5 = v 1 + v = v 6 = 4v = v 7 = v 4 + v = y = v Table I: An evaluation trace for y = (u 1 + u 2 ) sin(u 2 2) + 4(u 1 + u 2 2), with u 1 = 2, u 2 = 0.5. Suppose that we want to obtain the value of y with u 1 = 2 and u 2 = 0.5. The evaluation trace for one implementation of that computation is shown in Table I. It is by working with derivative information of the intermediate variables in the evaluation trace that AD can yield derivatives of the output variables y 1,..., y m with respect to the input variables u 1,..., u m. A popular technique for converting the original program to a program which can return derivatives is that of operator overloading. This technique works in programming languages which support operator overloading in object-oriented programming, such as C++ and Matlab. The idea is to introduce a new class, which in addition to storing the values of variables, also stores the values of derivatives. Then, as operations are carried out, not only are the variable values updated, but also the derivatives, according to the chain rule of calculus. We refer to [Griewank and Walther 2008] for how to incorporate the chain rule into computations, and further discussion of AD Obtaining syntax trees by operator overloading Rather than introducing a new class that in combination with operator overloading computes derivatives, we introduce a new class for obtaining syntax trees of mathematical expressions via operator overloading. We call this class treevar. Evaluating functions with treevar arguments yields their corresponding syntax trees, which is the first step for deriving the first order reformulation of erential equations. The fields of treevar objects are listed in Table II. For every property of the object, we define a function with the same name that returns the corresponding value. For example, if u k is a treevar object representing the intermediate variable u k in the evaluation trace, then height(u k ) is equal to the height field of u k. A crucial element of our algorithm for first order reformulation is propagating information about dependencies of variables. This is achieved with the ID field of the treevar object, which is a Boolean vector. Boolean vectors are elements of B n, the space of vectors with n elements that are either 0 or 1. We represent members of B n as row vectors. By r j, we mean the jth element of the vector r B n. To every intermediate variable u i in the evaluation trace, we associate the Boolean vector r (i). A value r (i) j = 1 indicates that the intermediate variable u i depends on the jth input variable, while r (i) j = 0 indicates that u i does not depend on the jth input variable.

5 AUTOMATIC REFORMULATION OF ODES A:5 method numargs center left right Order height ID hasterms The method leading to the construction of the variable. The number of arguments to the method The center node of the syntax tree (the argument to a univariate method). The left node of the syntax tree (the first argument to a bivariate method). The right node of the syntax tree (the second argument to a bivariate method). The erential order of the treevar, which represents how many the base variables have been erentiated when we arrive at the current treevar. Note that Order is vector valued, with the ith element equal to the highest derivative of the ith input variable that appears in the syntax tree. The height of the syntax tree, i.e., the number of operations between the base variables(s) and the current variable. A Boolean vector, whose ith element is equal to 1 if the treevar variable was constructed from the ith base variable, 0 otherwise. A Boolean that indicates whether a treevar is constructed from a sequence of computations that include multiple terms with dependent variables. Table II: Fields of the treevar object. We use the following standard Boolean algebra notation for vectors r, s, t B n : Logical OR. If t = r s, then t i = 1 iff r i = 1 or s i = 1 (or both). Before we evaluate the program defining the erential operator, we seed base variables that correspond to each unknown function in the erential equations. The base variables correspond to intermediate variables in the evaluation trace with index 0, and the seeding operation involves setting one element of the ID vector of the treevar object equal to 1. For example, for the Lorenz equations x = 10(y x) y = x(28 z) y z = xy 8 3 z (7) where we initialise the intermediate variables as we have u 2 = x, u 1 = y, u 0 = z, id(u 2 ) = [1 0 0], id(u 1 ) = [0 1 0] id(u 0 ) = [0 0 1]. (8) For erential equations where the independent (time) variable appears explicitly, the corresponding base variable gets seeded with an all-zero ID vector. After seeding the base variables, we now carry out the computations in the evaluation trace. The result of evaluating each elementary operator (with either one or two treevar arguments) will be another treevar variable, which gets further propagated in the trace. The values of the properties of the treevar object returned depend on the input variables and the type of the operator. In the Lorenz example above, we arrive at id(x ) = [1 1 0], id(y ) = [1 1 1], id(z ) = [1 1 1], (9) indicating that x depends on x and y, while y and z depend on all of x, y and z, as is clear from (7).

6 A:6 Ásgeir Birkisson method(v k ) = cos numargs(v k ) = 1 center(v k ) = v i id(v k ) = id(v i ) height(v k ) = height(v i ) + 1 order(v k ) = order(v i ) hasterms(v k ) = hasterms(v i ) Table III: Output rules for the elementary operation v k = cos(v i ), where v i and v k are intermediate treevar variables. method(v k ) = + numargs(v k ) = 2 left(v k ) = v i right(v k ) = v j id(v k ) = id(v i ) id(v j ) height(v k ) = max(height(v i ), height(v j )) + 1 order(v k ) = max(order(v i ), order(v j )) hasterms(v k ) = hasterms(v i ) hasterms(v j ) (elementwise) Table IV: Output rules for the elementary operation v k = v i + v j, where v i, v j and v k are intermediate treevar variables. To give an idea of the rules that treevar applies, we show the rules governing the output from the intermediate operators cos and + (which are prototypical for unary and binary operators respectively) in Tables III and IV. At the end of the evaluation, we will have obtained a syntax tree that can be either printed or plotted. For example, let the expression f = x + e y + cos(2t), (10) where t is the independent time variable of the problem and x = x(t), y = y(t) be given. Its syntax tree can be obtained and plotted (cf. Figure 1) as follows. >> t = treevar([0 0]); >> x = treevar([1 0]); >> y = treevar([0 1]) y = treevar with properties: Order: [0 0] hasterms: 0 height: 0 ID: [0 1] method: constr numargs: 0

7 AUTOMATIC REFORMULATION OF ODES A:7 plus plus cos exp u u t Fig. 1: A syntax tree of the expression f = x + e y + cos(2t). left: [] center: [] right: [] >> f = (x,2) + exp(y) + cos(2*t) f = treevar with properties: Order: [2 0] hasterms: 1 height: 3 ID: [1 1] method: plus numargs: 2 left: [1x1 treevar] center: [] right: [1x1 treevar] >> plot(f) Comparing the output from sequence above with Table II, we make the following observations: Since y is a base variable, its ID field is identical to what it was seeded with. In the syntax tree for f, both x and y appear, hence its ID field is [1 1]. The highest order derivative of x that appears in the syntax tree of f is 2, while no derivative of y is in the syntax tree of f. Thus, the Order field of f is [2 0]. y is a base variable, so its method is denoted to be the treevar constructor, and it has no children in the left, center or right fields. The method at the top of the syntax tree for f is +, and the treevar arguments of the + method are stored in the left and right fields of f Converting ODEs to a first order system We now describe how the syntax trees obtained by evaluating programs with treevar arguments are used to convert a system of quasilinear ODEs and a vector of righthand side values to a system of coupled first order ODEs. The essential algorithm is presented in Algorithm 2.1. It is implemented as the treevar method tofirstorder. The main algorithm makes use of some accompanying algorithms for working with syntax trees. These are: expandtree (implemented as the treevar method expandtree), which traverses syntax trees recursively to expand factors of input trees where highest order derivatives appear.

8 A:8 Ásgeir Birkisson splittree (implemented as the treevar method splittree), which traverses syntax trees recursively to split them into two trees. One of the trees contains the terms where the highest order derivatives of the input variables appear (this tree is used for determining the coefficient multiplying the highest order derivatives). The other tree contains the remaining terms. toinfix (implemented as the treevar method tree2infix), which recursively traverses syntax trees stored in treevar variables and converts them to infix form of the mathematical expressions they describe, using the method, left, center and right properties of treevar variables. All the treevar implementations of the algorithms are available and extensively documented in the code repository [Birkisson 2016]. In Figure 2, we show the results of the five main steps of Algorithm 2.1, namely, evaluating expressions, expanding the syntax tree, splitting the syntax tree, incorporating the right-hand side of the erential equation, and converting trees back to infix form. The erential equation we consider is 5t(u + uu ) = 2, (11) and the command for calling the treevar implementation of Algorithm 2.1 is funout = treevar.tofirstorder(@(t,u) 5*t.*((u,2)+u.*(u)), 2) While the computer generated output funout, shown in Figure 2e, isn t particularly human readable, it is perfectly acceptable as an input for the Matlab ODE solvers. We don t expect end users to ever have to work directly with the output from tofirstorder, instead, it can be passed straight to the Matlab solvers. 3. EXAMPLES Here, we show examples of how the treevar class can be used in Matlab for converting a higher order erential equation to a first order system, returning an anonymous function that we can evaluate to confirm it gives the expected results. We then pass the output from the first order reformulation to the Matlab ODE solvers to solve an initial value problem. Let the erential equations of interest be the equations governing linearly coupled anharmonic oscillators, which can exhibit chaotic dynamics for certain parameter choices [Steeb et al. 1987]. The equations are: with first order reformulation x + Ax + ax 3 + cy 2 = 0, y + Ay + ay 3 + cx 2 = 0, u 1 = u 2, u 2 = (A + au 2 1)u 1 cu 2 3, u 3 = u 4, u 4 = (A + au 2 3)u 3 cu 2 1. We begin by creating an anonymous function that defines the left-hand sides of the erential equations (12) in Matlab, which gets passed to the tofirstorder method of treevar. Note that the method is used to represent erentiation. We also pass to tofirstorder a vector containing the right-hand sides of the erential equations. The output is an another anonymous function that corresponds to the first order reformulation (13). We can evaluate that function at given values of t and u 1,..., u 4 and (12) (13)

9 AUTOMATIC REFORMULATION OF ODES A:9 plus 5.00 t u 2.00 u (a) Original syntax tree of the expression 5t(u + uu ) plus u t u t u u 1.00 (b) Expanded syntax tree 5.00 t u 5.00 t u 2.00 u 1.00 (c) After splitting syntax tree into two trees, one where highest order derivative appears, and another containing the remaining terms. minus t u u 1.00 (d) Incorporating the right-hand side of the erential equation funout (e) Infix form of the syntax tree above, which can be passed to Matlab s ODE solvers. Fig. 2: The results of the five main steps of the first order conversion algorithm, Algorithm 2.1, for the erential equation 5t(u + uu ) = 2.

10 A:10 Ásgeir Birkisson Algorithm 2.1 First order reformulation of ODEs. Input: A function f the specifies a system of quasilinear ordinary erential equations of arbitrary order. A vector r with entries for the right-hand sides of the erential equations. Output: A function g that corresponds to the first order reformulation of f and r. 1: m Number of dependent variables in the problem 2: n Number of erential equations in the problem 3: t treevar with id(t) = [0... 0] B m Indep. var. of the problem 4: for j = 1,..., m do Seed base variables 5: u j treevar with id(u j ) = [ ] B m (jth entry) 6: end for F will be an n-array of treevar variables, where the ith variable contains the syntax tree of the ith erential equation. 7: F f(t, u 1,..., u m ) Evaluate f with treevar arguments 8: D [0... 0] N m For storing order of highest deriv. of each var. 9: for k = 1,..., n do Determine highest derivatives of each input var. 10: D max(d, order(f k )) (elementwise) 11: end for Compute a vector that contains the indices of dependent variables in the reformulated problem. For example, if converting a system where u, v and w, are the highest order derivatives appearing, I = [1 3 6], since when the problem is written on its first order form, u = y 1, v = y 3 and w = y 6. 12: Let I N m, with I 1 = 1, I j = I j 1 + D j 1 for j 2. 13: for k = 1,..., n do Convert each erential equation to first order 14: T F k Work with the kth erential equation 15: T expandtree(t, D) Expand factors of syntax tree 16: T splittree(t, D) Split tree into derivative and non-derivative parts Create a new treevar to account for the rhs of the original erential equation 17: S treevar, with method(s) =, left(s) = r k and right(s) = T 18: g k toinfix(s, D, I) Convert syntax tree to infix form 19: end for 20: return g compare with the result of evaluating a manually constructed first order reformulation to confirm we obtained correct results. The code is given as follows: A = 0.3; a = 1; c = 1; % Specify coefficients % Define the second order coupled system of ODEs odefun [(x,2) + A*x + a*x.^3 + c*y.^2;... (y,2) + A*y + a*y.^3 + c*x.^2]; rhs = [0; 0]; % RHS of ODEs % Convert algorithmically to a first order system anonfun = treevar.tofirstorder(odefun, rhs); % The manually derived first order reformulation correctfun [u(2); -(A+a*u(1).^2)*u(1) - c*u(3).^2; u(4); -(A+a*u(3).^2)*u(3) - c*u(1).^2]; % Arbitrary values for t and u_1,..., u_4 to compare at: t = 1; evalpt = [ ]; norm(anonfun(t, evalpt) - correctfun(t, evalpt)) ans = e-14

11 AUTOMATIC REFORMULATION OF ODES A: (a) x y (x1(t) x2(t)) 2 +(y1(t) y2(t)) (b) Fig. 3: (a) Solution of the linearly coupled anharmonic oscillator (12), with initial conditions (14). (b) Separation of two pairs of trajectories (x 1, y 1 ) and (x 2, y 2 ), arising from slightly erent initial conditions, as t grows. We note that the erence between evaluating the automatically converted and the manually constructed anonymous functions is close to but not exactly 0. This is due to Matlab computing the answer by slightly erent sequences of floating point operations in the two cases. To solve the ODE (12), we can now pass the anonymous function obtained above to the ode113 solver along with time interval and the initial conditions 1, which we take to be x(0) = 0.7, x (0) = 0, y(0) = 0.8, y (0) = 0. (14) The treevar method solveivp takes care of all the steps required to compute a solution of an ODE, given anonymous functions specifying the erential equations and initial conditions, a vector for the right-hand sides of the equations and a pan on which the solution is to be computed. For this problem, we call it as follows: icfun [x -.7; (x); y -.8; (y)]; rhs = [0; 0]; odedom = [0 100]; [t, xy] = treevar.solveivp(odefun, icfun, rhs, odedom) We plot the solutions x and y in Figure 3a. Figure 3b shows how changing one of the initial conditions from x(0) = 0.7 to x(0) = results in erent trajectories that separate from the original ones as t grows, confirming that the system has a positive Lyaponov coefficient. 4. CHEBFUN AND TREEVAR The chebop class of Chebfun has the capability of solving nonlinear BVPs of ODEs in the continuous setting, implementing Newton s method in function space (which is often referred to as Newton-Kantorovich iteration). This is achieved using spectral methods in combination with automatic erentiation [Birkisson and Driscoll 2012]. However, such global methods are often ineffective for IVPs as they make no use of 1 We have also implemented a method sortconditions, which, given initial conditions specified for variables of the original problem, determines which conditions should be imposed to each variable in the reformulated problem. The chebop solver makes use of that method, as will be evident in the next section.

12 A:12 Ásgeir Birkisson the special structure of IVPs poor initial guesses can lead to the Newton iteration to fail, even when it is damped. The remedy for IVPs is to use tepping methods for computing a high accuracy solution to the problem, then convert the solution to a chebfun. This is done by the overloaded backslash (\) method of chebop. The default algorithm for solving an IVP with chebop is as follows: (1) Call the treevar class for automatically reformulating the problem. (2) Solve the problem using the ode113 solver of Matlab with a strict tolerance. (3) Sample the solution at finer and finer Chebyshev grids until the Chebyshev coefficients of the solution have decayed sufficiently. As an example of how IVPs can now be easily solved with chebop, here, we solve the van der Pol Equation (4) on the interval t [0, 100], with coefficient µ = 10 and initial conditions u(0) = 1, u (0) = 0. % Define a chebop on the time interval [0, 100]: N = chebop(@(t,u) (u, 2) - 10*(1-u^2)*(u) + u, [0 100]); % Impose initial conditions u(0) = 1, u (0) = 0. N.lbc = [1; 0]; % Call overloaded \ for solving: u = N\0; The solution is a chebfun object of length 14277, that is, a polynomial of degree In Figure 4a, we plot the solution, and in Figure 4b, we plot its Chebyshev coefficients, showing that we have resolved the solution to a high precision. Since the solution is a chebfun, we can carry out all the normal chebfun operations on it, such as finding all its local maxima (plotted as red stars in Figure 4a) and comparing the distance between them to determine the period of the oscillator. [maxval, maxpos] = max(u, local ); (maxpos(2:end-1)) ans = Another example we consider is the Rössler equations, a dynamical system that only has a single nonlinear term, yet still exhibits chaotic behaviour [Rössler 1976]. The equations are u = v w, v = u + 0.2v, w = w(u 5.7) (15) and we arbitrarily pick the initial conditions u(0) = 4, v(0) = 0, w(0) = 0. The code for setting up and solving the problem for t [0, 100] is as follows: % Assign the erential equation to a chebop on our selected domain N = chebop(@(t,u,v,w) [(u) + v + w; (v) - u - 0.2*v; (w) w*(u - 5.7)], [0 100]); % Assign boundary conditions to the chebop. N.lbc v, w) [u+4; v; w];

13 AUTOMATIC REFORMULATION OF ODES A: Magnitude of coefficient (a) Degree of Chebyshev polynomial (b) Fig. 4: (a) Solution of the van der Pol ODE (5) with initial conditions u(0) = 1, u (0) = 0. Local maxima are plotted as red stars. (b) Chebyshev coefficients of the computed solution w v u Fig. 5: The Rössler attractor for Equations (15). % Solve and plot solution compomentents against each other [u, v, w] = N\0; plot3(u, v, w) The presence of a strange attractor is evident from a 3D plot of the solution components, shown in Figure 5. As a final example of what treevar has enabled for the chebop class, we mention the quiver method for plotting phase plane portraits of second order scalar ODEs (first order coupled systems of two functions are also supported). Given a chebop, the method obtains the first order reformulation of its erential equation, which is then used to compute a vector field that is passed to the built-in quiver method of Matlab for

14 A:14 Ásgeir Birkisson θ θ Fig. 6: Phase portrait for the damped nonlinear pendulum (16), showing trajectories for erent initial velocities. plotting. The following code plots a phase portrait for the damped nonlinear pendulum: θ θ + sin(θ) = 0. (16) It then computes trajectories for erent initial velocities and overlays them on the plot, shown in Figure 6. Notice that while trajectories with high enough initial velocities are able to swing around a few, eventually, they all are brought to rest at the pendulum s stable equilibrium. % Define a chebop N = chebop(@(t,theta) (theta,2)+(theta)/4+sin(theta),[0 50]); % Call quiver, specifying upper and lower limits of axes: quiver(n, [ ]) % Overlay trajectories for erent initial velocities hold on for init = 0:0.5:5 N.lbc = [0; init]; theta = N\0; plot(theta, (theta)) end hold off 5. CONCLUSION AND FURTHER WORK We have shown how the introduction of the treevar class enables us to algorithmically convert a higher order erential equation to a system of first order equations. This allows us to call standard ODE solvers such as Matlab s ode45 and ode113 on problems that are described more closely to their natural mathematical form. In particular, for Chebfun, it allowed the chebop class to apply time-stepping algorithms to IVPs, rather than global spectral methods. This led to a much more robust solver for IVPs, avoiding issues with diverging Newton s method for poor initial guesses. It also offers easy plotting of phase portraits for ODEs. A significant part of the demonstrations in the

15 AUTOMATIC REFORMULATION OF ODES A:15 forthcoming ODE textbook [Trefethen et al. 2017] were enabled by capabilities treevar introduced. We believe that the structural analysis of mathematical problems, such as implemented here with treevar, has many other possible applications in scientific computing software, especially for offering users a convenient syntax while applying powerful algorithms under the hood. We have already started investigating applications for optimal control problems, as well as for splitting PDE operators into linear and nonlinear parts for exponential integrators [Cox and Matthews 2002; Kassam and Trefethen 2005]. ACKNOWLEDGMENTS The author would like to thank Nick Trefethen for the many comments, suggestions and revisions while working on this article. REFERENCES U. Ascher and R. D. Russell Reformulation of boundary value problems into standard form. SIAM Rev. 23, 2 (1981), DOI: Á. Birkisson The treevar class for automatic reformulation of ODEs to first order systems. https: //github.com/asgeirbirkis/treevar. (2016). Á. Birkisson and T. A. Driscoll Automatic Fréchet erentiation for the numerical solution of boundary-value problems. ACM Trans. Math. Softw. 38, 4, Article 26 (2012), 29 pages. DOI: S. M. Cox and P. C. Matthews Exponential time erencing for stiff systems. J. Comput. Phys. 176, 2 (March 2002), DOI: T. A. Driscoll, N. Hale, and L. N. Trefethen (Eds.) Chebfun Guide. Pafnuty Publications, Oxford. A. Griewank and A. Walther Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation (2nd ed.). SIAM, Philadelphia. E. Hairer, S. P. Nørsett, and G. Wanner Solving Ordinary Differential Equations I: Nonstiff Problems (2nd revised ed.). Springer Berlin Heidelberg. A.-K. Kassam and L. N. Trefethen Fourth-order time-stepping for stiff PDEs. SIAM J. Sci. Comput. 26, 4 (April 2005), DOI: R. D. Neidinger Introduction to automatic erentiation and MATLAB object-oriented programming. SIAM Rev. 52, 3 (2010), DOI: O. E. Rössler An equation for continuous chaos. Physics Letters A 57, 5 (1976), DOI: L. F. Shampine and M. W. Reichelt The MATLAB ODE Suite. SIAM J. Sci. Comput. 18, 1 (Jan. 1997), DOI: W.-H. Steeb, J. A. Louw, and C. M. Villet Linearly coupled anharmonic oscillators and integrability. Aust. J. Phys. 40, 5 (Oct. 1987), J. Stoer and R. Bulirsch Introduction to Numerical Analysis. Springer. S. H. Strogatz Nonlinear Dynamics and Chaos: With Applications to Physics, Biology, Chemistry, and Engineering. Westview Press. L. N. Trefethen, Á. Birkisson, and T. A. Driscoll Exploring ODEs. (2017). In preparation. B. van der Pol On relaxation-oscillations. The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science 2, 11 (1926), DOI: L. Verlet Computer experiments on classical fluids. I. Thermodynamical properties of Lennard-Jones molecules. Phys. Rev. 159 (Jul 1967), Issue 1. DOI:

The automatic solution of PDEs using a global spectral method

The automatic solution of PDEs using a global spectral method The automatic solution of PDEs using a global spectral method 2014 CBMS-NSF Conference, 29th June 2014 Alex Townsend PhD student University of Oxford (with Sheehan Olver) Supervised by Nick Trefethen,

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

Chebfun2: Exploring Constant Coefficient PDEs on Rectangles

Chebfun2: Exploring Constant Coefficient PDEs on Rectangles Chebfun2: Exploring Constant Coefficient PDEs on Rectangles Alex Townsend Oxford University with Sheehan Olver, Sydney University FUN13 workshop, 11th of April 2013 Alex Townsend Constant coefficient PDEs

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

Multistep Methods for IVPs. t 0 < t < T

Multistep Methods for IVPs. t 0 < t < T Multistep Methods for IVPs We are still considering the IVP dy dt = f(t,y) t 0 < t < T y(t 0 ) = y 0 So far we have looked at Euler s method, which was a first order method and Runge Kutta (RK) methods

More information

Boyce/DiPrima/Meade 11 th ed, Ch 1.1: Basic Mathematical Models; Direction Fields

Boyce/DiPrima/Meade 11 th ed, Ch 1.1: Basic Mathematical Models; Direction Fields Boyce/DiPrima/Meade 11 th ed, Ch 1.1: Basic Mathematical Models; Direction Fields Elementary Differential Equations and Boundary Value Problems, 11 th edition, by William E. Boyce, Richard C. DiPrima,

More information

Scientific Computing: An Introductory Survey

Scientific Computing: An Introductory Survey Scientific Computing: An Introductory Survey Chapter 9 Initial Value Problems for Ordinary Differential Equations Prof. Michael T. Heath Department of Computer Science University of Illinois at Urbana-Champaign

More information

An Overly Simplified and Brief Review of Differential Equation Solution Methods. 1. Some Common Exact Solution Methods for Differential Equations

An Overly Simplified and Brief Review of Differential Equation Solution Methods. 1. Some Common Exact Solution Methods for Differential Equations An Overly Simplified and Brief Review of Differential Equation Solution Methods We will be dealing with initial or boundary value problems. A typical initial value problem has the form y y 0 y(0) 1 A typical

More information

CS 450 Numerical Analysis. Chapter 9: Initial Value Problems for Ordinary Differential Equations

CS 450 Numerical Analysis. Chapter 9: Initial Value Problems for Ordinary Differential Equations Lecture slides based on the textbook Scientific Computing: An Introductory Survey by Michael T. Heath, copyright c 2018 by the Society for Industrial and Applied Mathematics. http://www.siam.org/books/cl80

More information

Research Article A Note on the Solutions of the Van der Pol and Duffing Equations Using a Linearisation Method

Research Article A Note on the Solutions of the Van der Pol and Duffing Equations Using a Linearisation Method Mathematical Problems in Engineering Volume 1, Article ID 693453, 1 pages doi:11155/1/693453 Research Article A Note on the Solutions of the Van der Pol and Duffing Equations Using a Linearisation Method

More information

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 9

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 9 Lecture Notes to Accompany Scientific Computing An Introductory Survey Second Edition by Michael T. Heath Chapter 9 Initial Value Problems for Ordinary Differential Equations Copyright c 2001. Reproduction

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

Ordinary Differential Equations

Ordinary Differential Equations CHAPTER 8 Ordinary Differential Equations 8.1. Introduction My section 8.1 will cover the material in sections 8.1 and 8.2 in the book. Read the book sections on your own. I don t like the order of things

More information

Southern Methodist University.

Southern Methodist University. Title: Continuous extensions Name: Lawrence F. Shampine 1, Laurent O. Jay 2 Affil./Addr. 1: Department of Mathematics Southern Methodist University Dallas, TX 75275 USA Phone: +1 (972) 690-8439 E-mail:

More information

Numerical Methods for Ordinary Differential Equations

Numerical Methods for Ordinary Differential Equations CHAPTER 1 Numerical Methods for Ordinary Differential Equations In this chapter we discuss numerical method for ODE. We will discuss the two basic methods, Euler s Method and Runge-Kutta Method. 1. Numerical

More information

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

Scientific Computing with Case Studies SIAM Press, Lecture Notes for Unit V Solution of Scientific Computing with Case Studies SIAM Press, 2009 http://www.cs.umd.edu/users/oleary/sccswebpage Lecture Notes for Unit V Solution of Differential Equations Part 1 Dianne P. O Leary c 2008 1 The

More information

Initial value problems for ordinary differential equations

Initial value problems for ordinary differential equations AMSC/CMSC 660 Scientific Computing I Fall 2008 UNIT 5: Numerical Solution of Ordinary Differential Equations Part 1 Dianne P. O Leary c 2008 The Plan Initial value problems (ivps) for ordinary differential

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

CDS 101 Precourse Phase Plane Analysis and Stability

CDS 101 Precourse Phase Plane Analysis and Stability CDS 101 Precourse Phase Plane Analysis and Stability Melvin Leok Control and Dynamical Systems California Institute of Technology Pasadena, CA, 26 September, 2002. mleok@cds.caltech.edu http://www.cds.caltech.edu/

More information

Butcher tableau Can summarize an s + 1 stage Runge Kutta method using a triangular grid of coefficients

Butcher tableau Can summarize an s + 1 stage Runge Kutta method using a triangular grid of coefficients AM 205: lecture 13 Last time: ODE convergence and stability, Runge Kutta methods Today: the Butcher tableau, multi-step methods, boundary value problems Butcher tableau Can summarize an s + 1 stage Runge

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

A fast and well-conditioned spectral method: The US method

A fast and well-conditioned spectral method: The US method A fast and well-conditioned spectral method: The US method Alex Townsend University of Oxford Leslie Fox Prize, 24th of June 23 Partially based on: S. Olver & T., A fast and well-conditioned spectral method,

More information

Lecture 8: Calculus and Differential Equations

Lecture 8: Calculus and Differential Equations Lecture 8: Calculus and Differential Equations Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 9. Numerical Methods MATLAB provides

More information

Lecture 8: Calculus and Differential Equations

Lecture 8: Calculus and Differential Equations Lecture 8: Calculus and Differential Equations Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE21: Computer Applications. See Textbook Chapter 9. Numerical Methods MATLAB provides

More information

Solving systems of first order equations with ode Systems of first order differential equations.

Solving systems of first order equations with ode Systems of first order differential equations. A M S 20 MA TLA B NO T E S U C S C Solving systems of first order equations with ode45 c 2015, Yonatan Katznelson The M A T L A B numerical solver, ode45 is designed to work with first order differential

More information

Ordinary Differential Equations. Monday, October 10, 11

Ordinary Differential Equations. Monday, October 10, 11 Ordinary Differential Equations Monday, October 10, 11 Problems involving ODEs can always be reduced to a set of first order differential equations. For example, By introducing a new variable z, this can

More information

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

The Plan. Initial value problems (ivps) for ordinary differential equations (odes) Review of basic methods You are here: Hamiltonian systems Scientific Computing with Case Studies SIAM Press, 2009 http://www.cs.umd.edu/users/oleary/sccswebpage Lecture Notes for Unit V Solution of Differential Equations Part 2 Dianne P. O Leary c 2008 The Plan

More information

Physically Based Modeling Differential Equation Basics

Physically Based Modeling Differential Equation Basics Physically Based Modeling Differential Equation Basics Andrew Witkin and David Baraff Pixar Animation Studios Please note: This document is 2001 by Andrew Witkin and David Baraff. This chapter may be freely

More information

AM 205 Final Project The N-Body Problem

AM 205 Final Project The N-Body Problem AM 205 Final Project The N-Body Problem Leah Birch Elizabeth Finn Karen Yu December 14, 2012 Abstract The N-Body Problem can be solved using a variety of numeric integrators. Newton s Law of Universal

More information

ACM/CMS 107 Linear Analysis & Applications Fall 2016 Assignment 4: Linear ODEs and Control Theory Due: 5th December 2016

ACM/CMS 107 Linear Analysis & Applications Fall 2016 Assignment 4: Linear ODEs and Control Theory Due: 5th December 2016 ACM/CMS 17 Linear Analysis & Applications Fall 216 Assignment 4: Linear ODEs and Control Theory Due: 5th December 216 Introduction Systems of ordinary differential equations (ODEs) can be used to describe

More information

The integrating factor method (Sect. 1.1)

The integrating factor method (Sect. 1.1) The integrating factor method (Sect. 1.1) Overview of differential equations. Linear Ordinary Differential Equations. The integrating factor method. Constant coefficients. The Initial Value Problem. Overview

More information

Physically Based Modeling: Principles and Practice Differential Equation Basics

Physically Based Modeling: Principles and Practice Differential Equation Basics Physically Based Modeling: Principles and Practice Differential Equation Basics Andrew Witkin and David Baraff Robotics Institute Carnegie Mellon University Please note: This document is 1997 by Andrew

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

16.7 Multistep, Multivalue, and Predictor-Corrector Methods

16.7 Multistep, Multivalue, and Predictor-Corrector Methods 740 Chapter 16. Integration of Ordinary Differential Equations 16.7 Multistep, Multivalue, and Predictor-Corrector Methods The terms multistepand multivaluedescribe two different ways of implementing essentially

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

AIMS Exercise Set # 1

AIMS Exercise Set # 1 AIMS Exercise Set #. Determine the form of the single precision floating point arithmetic used in the computers at AIMS. What is the largest number that can be accurately represented? What is the smallest

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

Why are Discrete Maps Sufficient?

Why are Discrete Maps Sufficient? Why are Discrete Maps Sufficient? Why do dynamical systems specialists study maps of the form x n+ 1 = f ( xn), (time is discrete) when much of the world around us evolves continuously, and is thus well

More information

n-dimensional LCE code

n-dimensional LCE code n-dimensional LCE code Dale L Peterson Department of Mechanical and Aeronautical Engineering University of California, Davis dlpeterson@ucdavisedu June 10, 2007 Abstract The Lyapunov characteristic exponents

More information

The Initial Value Problem for Ordinary Differential Equations

The Initial Value Problem for Ordinary Differential Equations Chapter 5 The Initial Value Problem for Ordinary Differential Equations In this chapter we begin a study of time-dependent differential equations, beginning with the initial value problem (IVP) for a time-dependent

More information

Question: Total. Points:

Question: Total. Points: MATH 308 May 23, 2011 Final Exam Name: ID: Question: 1 2 3 4 5 6 7 8 9 Total Points: 0 20 20 20 20 20 20 20 20 160 Score: There are 9 problems on 9 pages in this exam (not counting the cover sheet). Make

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

Boundary Layer Problems and Applications of Spectral Methods

Boundary Layer Problems and Applications of Spectral Methods Boundary Layer Problems and Applications of Spectral Methods Sumi Oldman University of Massachusetts Dartmouth CSUMS Summer 2011 August 4, 2011 Abstract Boundary layer problems arise when thin boundary

More information

A Note on the Recursive Calculation of Incomplete Gamma Functions

A Note on the Recursive Calculation of Incomplete Gamma Functions A Note on the Recursive Calculation of Incomplete Gamma Functions WALTER GAUTSCHI Purdue University It is known that the recurrence relation for incomplete gamma functions a n, x, 0 a 1, n 0,1,2,..., when

More information

Applied Linear Algebra in Geoscience Using MATLAB

Applied Linear Algebra in Geoscience Using MATLAB Applied Linear Algebra in Geoscience Using MATLAB Contents Getting Started Creating Arrays Mathematical Operations with Arrays Using Script Files and Managing Data Two-Dimensional Plots Programming in

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

Ordinary Differential Equations (ODEs)

Ordinary Differential Equations (ODEs) Ordinary Differential Equations (ODEs) 1 Computer Simulations Why is computation becoming so important in physics? One reason is that most of our analytical tools such as differential calculus are best

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

Introduction to Finite Di erence Methods

Introduction to Finite Di erence Methods Introduction to Finite Di erence Methods ME 448/548 Notes Gerald Recktenwald Portland State University Department of Mechanical Engineering gerry@pdx.edu ME 448/548: Introduction to Finite Di erence Approximation

More information

Solutions To Odes And Pdes Numerical Analysis Using R

Solutions To Odes And Pdes Numerical Analysis Using R We have made it easy for you to find a PDF Ebooks without any digging. And by having access to our ebooks online or by storing it on your computer, you have convenient answers with solutions to odes and

More information

Lecture 1: Introduction, history, dynamics, nonlinearity, 1-D problem, phase portrait

Lecture 1: Introduction, history, dynamics, nonlinearity, 1-D problem, phase portrait Lecture 1: Introduction, history, dynamics, nonlinearity, 1-D problem, phase portrait Dmitri Kartofelev, PhD Tallinn University of Technology, School of Science, Department of Cybernetics, Laboratory of

More information

Introduction - Motivation. Many phenomena (physical, chemical, biological, etc.) are model by differential equations. f f(x + h) f(x) (x) = lim

Introduction - Motivation. Many phenomena (physical, chemical, biological, etc.) are model by differential equations. f f(x + h) f(x) (x) = lim Introduction - Motivation Many phenomena (physical, chemical, biological, etc.) are model by differential equations. Recall the definition of the derivative of f(x) f f(x + h) f(x) (x) = lim. h 0 h Its

More information

CS520: numerical ODEs (Ch.2)

CS520: numerical ODEs (Ch.2) .. CS520: numerical ODEs (Ch.2) Uri Ascher Department of Computer Science University of British Columbia ascher@cs.ubc.ca people.cs.ubc.ca/ ascher/520.html Uri Ascher (UBC) CPSC 520: ODEs (Ch. 2) Fall

More information

Delay Differential Equations with Constant Lags

Delay Differential Equations with Constant Lags Delay Differential Equations with Constant Lags L.F. Shampine Mathematics Department Southern Methodist University Dallas, TX 75275 shampine@smu.edu S. Thompson Department of Mathematics & Statistics Radford

More information

Lecture 4: Numerical solution of ordinary differential equations

Lecture 4: Numerical solution of ordinary differential equations Lecture 4: Numerical solution of ordinary differential equations Department of Mathematics, ETH Zürich General explicit one-step method: Consistency; Stability; Convergence. High-order methods: Taylor

More information

Estimating the Region of Attraction of Ordinary Differential Equations by Quantified Constraint Solving

Estimating the Region of Attraction of Ordinary Differential Equations by Quantified Constraint Solving Estimating the Region of Attraction of Ordinary Differential Equations by Quantified Constraint Solving Henning Burchardt and Stefan Ratschan October 31, 2007 Abstract We formulate the problem of estimating

More information

Integration of Ordinary Differential Equations

Integration of Ordinary Differential Equations Integration of Ordinary Differential Equations Com S 477/577 Nov 7, 00 1 Introduction The solution of differential equations is an important problem that arises in a host of areas. Many differential equations

More information

Total Ordering on Subgroups and Cosets

Total Ordering on Subgroups and Cosets Total Ordering on Subgroups and Cosets Alexander Hulpke Department of Mathematics Colorado State University 1874 Campus Delivery Fort Collins, CO 80523-1874 hulpke@math.colostate.edu Steve Linton Centre

More information

Geometric Numerical Integration

Geometric Numerical Integration Geometric Numerical Integration (Ernst Hairer, TU München, winter 2009/10) Development of numerical ordinary differential equations Nonstiff differential equations (since about 1850), see [4, 2, 1] Adams

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

DIFFERENTIAL EQUATIONS, DYNAMICAL SYSTEMS, AND AN INTRODUCTION TO CHAOS

DIFFERENTIAL EQUATIONS, DYNAMICAL SYSTEMS, AND AN INTRODUCTION TO CHAOS DIFFERENTIAL EQUATIONS, DYNAMICAL SYSTEMS, AND AN INTRODUCTION TO CHAOS Morris W. Hirsch University of California, Berkeley Stephen Smale University of California, Berkeley Robert L. Devaney Boston University

More information

Solving PDEs with PGI CUDA Fortran Part 4: Initial value problems for ordinary differential equations

Solving PDEs with PGI CUDA Fortran Part 4: Initial value problems for ordinary differential equations Solving PDEs with PGI CUDA Fortran Part 4: Initial value problems for ordinary differential equations Outline ODEs and initial conditions. Explicit and implicit Euler methods. Runge-Kutta methods. Multistep

More information

PH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Abstract

PH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Abstract PH36010: Numerical Methods - Evaluating the Lorenz Attractor using Runge-Kutta methods Mr. Benjamen P. Reed (110108461) IMPACS, Aberystwyth University January 31, 2014 Abstract A set of three coupled ordinary

More information

Value Problems Introduction

Value Problems Introduction Chapter 17. 17.0 Introduction Two Point Boundary Value Problems When ordinary differential equations are to satisfy conditions at more than one of the independent variable, the resulting problem is called

More information

Department of Economics. Issn Discussion paper 30/09

Department of Economics. Issn Discussion paper 30/09 Department of Economics Issn 1441-5429 Discussion paper 30/09 Solving Macroeconomic Models with "Off-the-Shelf" Software: An Example of Potential Pitfalls Ric D. Herbert a and Peter J. Stemp b,* Abstract:

More information

DIFFERENTIAL EQUATIONS

DIFFERENTIAL EQUATIONS DIFFERENTIAL EQUATIONS Basic Concepts Paul Dawkins Table of Contents Preface... Basic Concepts... 1 Introduction... 1 Definitions... Direction Fields... 8 Final Thoughts...19 007 Paul Dawkins i http://tutorial.math.lamar.edu/terms.aspx

More information

REVIEW: The Matching Method Algorithm

REVIEW: The Matching Method Algorithm Lecture 26: Numerov Algorithm for Solving the Time-Independent Schrödinger Equation 1 REVIEW: The Matching Method Algorithm Need for a more general method The shooting method for solving the time-independent

More information

Kasetsart University Workshop. Multigrid methods: An introduction

Kasetsart University Workshop. Multigrid methods: An introduction Kasetsart University Workshop Multigrid methods: An introduction Dr. Anand Pardhanani Mathematics Department Earlham College Richmond, Indiana USA pardhan@earlham.edu A copy of these slides is available

More information

An Introduction to Numerical Methods for Differential Equations. Janet Peterson

An Introduction to Numerical Methods for Differential Equations. Janet Peterson An Introduction to Numerical Methods for Differential Equations Janet Peterson Fall 2015 2 Chapter 1 Introduction Differential equations arise in many disciplines such as engineering, mathematics, sciences

More information

CS 257: Numerical Methods

CS 257: Numerical Methods CS 57: Numerical Methods Final Exam Study Guide Version 1.00 Created by Charles Feng http://www.fenguin.net CS 57: Numerical Methods Final Exam Study Guide 1 Contents 1 Introductory Matter 3 1.1 Calculus

More information

Compound Damped Pendulum: An Example

Compound Damped Pendulum: An Example Compound Damped Pendulum: An Example Temple H. Fay Department of Mathematical Technology 1 Tshwane University of Technology Pretoria, South Africa thf ay@hotmail:com Abstract: In this article, we use an

More information

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

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University Part 3 Chapter 10 LU Factorization PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

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

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

Exponentially Fitted Error Correction Methods for Solving Initial Value Problems

Exponentially Fitted Error Correction Methods for Solving Initial Value Problems KYUNGPOOK Math. J. 52(2012), 167-177 http://dx.doi.org/10.5666/kmj.2012.52.2.167 Exponentially Fitted Error Correction Methods for Solving Initial Value Problems Sangdong Kim and Philsu Kim Department

More information

DIFFERENTIAL EQUATIONS, DYNAMICAL SYSTEMS, AND AN INTRODUCTION TO CHAOS

DIFFERENTIAL EQUATIONS, DYNAMICAL SYSTEMS, AND AN INTRODUCTION TO CHAOS DIFFERENTIAL EQUATIONS, DYNAMICAL SYSTEMS, AND AN INTRODUCTION TO CHAOS Morris W. Hirsch University of California, Berkeley Stephen Smale University of California, Berkeley Robert L. Devaney Boston University

More information

Reducing round-off errors in symmetric multistep methods

Reducing round-off errors in symmetric multistep methods Reducing round-off errors in symmetric multistep methods Paola Console a, Ernst Hairer a a Section de Mathématiques, Université de Genève, 2-4 rue du Lièvre, CH-1211 Genève 4, Switzerland. (Paola.Console@unige.ch,

More information

NAG Library Chapter Introduction d02 Ordinary Differential Equations

NAG Library Chapter Introduction d02 Ordinary Differential Equations NAG Library Chapter Introduction d02 Ordinary Differential Equations Contents 1 Scope of the Chapter.... 2 2 Background to the Problems... 2 2.1 Initial Value Problems... 3 2.2 Boundary Value Problems...

More information

Differential Equations 2280 Sample Midterm Exam 3 with Solutions Exam Date: 24 April 2015 at 12:50pm

Differential Equations 2280 Sample Midterm Exam 3 with Solutions Exam Date: 24 April 2015 at 12:50pm Differential Equations 228 Sample Midterm Exam 3 with Solutions Exam Date: 24 April 25 at 2:5pm Instructions: This in-class exam is 5 minutes. No calculators, notes, tables or books. No answer check is

More information

APPM 2460 CHAOTIC DYNAMICS

APPM 2460 CHAOTIC DYNAMICS APPM 2460 CHAOTIC DYNAMICS 1. Introduction Today we ll continue our exploration of dynamical systems, focusing in particular upon systems who exhibit a type of strange behavior known as chaos. We will

More information

Computer Problems for Methods of Solving Ordinary Differential Equations

Computer Problems for Methods of Solving Ordinary Differential Equations Computer Problems for Methods of Solving Ordinary Differential Equations 1. Have a computer make a phase portrait for the system dx/dt = x + y, dy/dt = 2y. Clearly indicate critical points and separatrices.

More information

Lösning: Tenta Numerical Analysis för D, L. FMN011,

Lösning: Tenta Numerical Analysis för D, L. FMN011, Lösning: Tenta Numerical Analysis för D, L. FMN011, 090527 This exam starts at 8:00 and ends at 12:00. To get a passing grade for the course you need 35 points in this exam and an accumulated total (this

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

Math 312 Lecture Notes Linear Two-dimensional Systems of Differential Equations

Math 312 Lecture Notes Linear Two-dimensional Systems of Differential Equations Math 2 Lecture Notes Linear Two-dimensional Systems of Differential Equations Warren Weckesser Department of Mathematics Colgate University February 2005 In these notes, we consider the linear system of

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

A Mathematica Companion for Differential Equations

A Mathematica Companion for Differential Equations iii A Mathematica Companion for Differential Equations Selwyn Hollis PRENTICE HALL, Upper Saddle River, NJ 07458 iv v Contents Preface viii 0. An Introduction to Mathematica 0.1 Getting Started 1 0.2 Functions

More information

Math 266: Phase Plane Portrait

Math 266: Phase Plane Portrait Math 266: Phase Plane Portrait Long Jin Purdue, Spring 2018 Review: Phase line for an autonomous equation For a single autonomous equation y = f (y) we used a phase line to illustrate the equilibrium solutions

More information

Geometric interpretation of signals: background

Geometric interpretation of signals: background Geometric interpretation of signals: background David G. Messerschmitt Electrical Engineering and Computer Sciences University of California at Berkeley Technical Report No. UCB/EECS-006-9 http://www.eecs.berkeley.edu/pubs/techrpts/006/eecs-006-9.html

More information

Differential Equations FMNN10 Graded Project #1 c G Söderlind 2017

Differential Equations FMNN10 Graded Project #1 c G Söderlind 2017 Differential Equations FMNN10 Graded Project #1 c G Söderlind 2017 Published 2017-10-30. Instruction in computer lab 2017-11-02/08/09. Project report due date: Monday 2017-11-13 at 10:00. Goals. The goal

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

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

NUMERICAL METHODS. lor CHEMICAL ENGINEERS. Using Excel', VBA, and MATLAB* VICTOR J. LAW. CRC Press. Taylor & Francis Group

NUMERICAL METHODS. lor CHEMICAL ENGINEERS. Using Excel', VBA, and MATLAB* VICTOR J. LAW. CRC Press. Taylor & Francis Group NUMERICAL METHODS lor CHEMICAL ENGINEERS Using Excel', VBA, and MATLAB* VICTOR J. LAW CRC Press Taylor & Francis Group Boca Raton London New York CRC Press is an imprint of the Taylor & Francis Croup,

More information

Control Systems. Internal Stability - LTI systems. L. Lanari

Control Systems. Internal Stability - LTI systems. L. Lanari Control Systems Internal Stability - LTI systems L. Lanari outline LTI systems: definitions conditions South stability criterion equilibrium points Nonlinear systems: equilibrium points examples stable

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

Dynamics and Time Integration. Computer Graphics CMU /15-662, Fall 2016

Dynamics and Time Integration. Computer Graphics CMU /15-662, Fall 2016 Dynamics and Time Integration Computer Graphics CMU 15-462/15-662, Fall 2016 Last Quiz: IK (and demo) Last few classes Keyframing and motion capture - Q: what can one NOT do with these techniques? The

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

Chapter 1 Mathematical Preliminaries and Error Analysis

Chapter 1 Mathematical Preliminaries and Error Analysis Numerical Analysis (Math 3313) 2019-2018 Chapter 1 Mathematical Preliminaries and Error Analysis Intended learning outcomes: Upon successful completion of this chapter, a student will be able to (1) list

More information

Mathematical Models. MATH 365 Ordinary Differential Equations. J. Robert Buchanan. Fall Department of Mathematics

Mathematical Models. MATH 365 Ordinary Differential Equations. J. Robert Buchanan. Fall Department of Mathematics Mathematical Models MATH 365 Ordinary Differential Equations J. Robert Buchanan Department of Mathematics Fall 2018 Ordinary Differential Equations The topic of ordinary differential equations (ODEs) is

More information

Mathematical Models. MATH 365 Ordinary Differential Equations. J. Robert Buchanan. Spring Department of Mathematics

Mathematical Models. MATH 365 Ordinary Differential Equations. J. Robert Buchanan. Spring Department of Mathematics Mathematical Models MATH 365 Ordinary Differential Equations J. Robert Buchanan Department of Mathematics Spring 2018 Ordinary Differential Equations The topic of ordinary differential equations (ODEs)

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