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
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
(°Â¾±³Ù³óÌý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...
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. |