Delta Banner

Mathematics & Science Learning Center
Computer Laboratory

 

Solving Systems

Solving the Preliminary Example

(continued from last page...)

Solving the Problem Numerically

Let me remind you of the syntax of Mathematica's numerical differential equation solver:

?NDSolve

NDSolve Syntax

The syntax check shows us five possible versions of NDSolve, but a careful reading reveals that the last version is the one that we'll need:

"NDSolve[eqns,{u1,u2,…},] solves for the functions ui."

Notice the reference to functions, in the plural! We have two functions in our system that we wish to find, so this is the form of the command we'll use.

So far the problem that we have been working has been a simple system of differential equations, but in order to find a numerical solution we need to get more specific, remember? What is it that we're missing? I hope you said initial conditions. Numerical solvers work on initial value problems, and we need to have some initial conditions to turn our system into one.

Now when I proposed the solution that we spent so long checking a little earlier, I had a specific pair of initial conditions in mind, namely:

  • x(0) = 1
  • y(0) = 1

(With systems of differential equations, the initial conditions will look similar to the way they did with single equations, only you'll have a set of them—only one in this case, since it's first order—for each dependent variable in the problem.)

Putting these together with our original system we get the larger system:

x' = y - x - e3t  
y' = 3y + 2x - 2e- t  
x(0) = 1  
y(0) = 1  

These equations can be inserted into the NDSolve command, but we need one other piece of information. The numerical solver requires that we specify a finite interval upon which the solution is to be found. Since our initial condition is at 0, let's sandwich this value with our solution using the interval -2 ≤ t ≤ 2.

If we wish to read the result into the variable prelimsol, the command we'll use will be:

prelimsol= NDSolve[{x'[t]== y[t]- x[t]- E^(3t), y'[t]==3 y[t]+2 x[t]-2 E^(-t), x[0]==1,y[0]==1}, {x[t],y[t]},{t,-2,2}]

Let's go try it out. Come back here when you're done.

Now let's look at what you should have gotten...


Compass If you're lost, impatient, want an overview of this laboratory assignment, or maybe even all three, you can click on the compass button on the left to go to the table of contents for this laboratory assignment.
 
 

ODE Laboratories: A Sabbatical Project by Christopher A. Barker

©2017 San Joaquin Delta College, 5151 Pacific Ave., Stockton, CA 95207, USA
e-mail:
cbarker@deltacollege.edu