Solving Differential Equations with Mathematica's Solver
(continued fromÌýlast page...)
Did you get that right hand side figured out? TheÌýMathematicaÌýmini-session you just had should have looked something like this:
Integrate[2x E^(x^2),x]
Integrate[Sin[y]^2 Cos[y],y]
MathematicaÌýleaves off the constants of integration, so we must supply these mentally. It is worth noting here thatÌýMathematica's integration of the right-hand side of the differential equation takes on a far different form from the result you would most likely get if you were to evaluate the integral by hand, (most likely by using substitution.) This kind of behavior is quite typical of most computer algebra systems, and can be fairly frustrating at times. Anyway, looking over your results, and setting both sides equal to one another, you should realize that the (implicit) solution to the original differential equation is:

Notice that we have supplied theÌýCÌýourselves. This solution could be made explicit with a little work, (multiply both sides by 3, take the cube root of both sides, and then the arcsine,) but that's not our main concern right now. We're here to learn aboutÌýMathematica's differential equation solver.
So what about thisÌýDSolveÌýcommand?
Before we can use theÌýDSolveÌýcommand the differential equation must be put inÌýderivativeÌýform, whereas in the original differential equation it's inÌýdifferentialÌýform. To achieve the change we divide the original differential equation:
on both sides byÌýdx, giving:
and replace the (dy/dx) by the notationÌý²â′Ìý(y-prime):
We're about to feed this equation intoÌýMathematica'sÌýDSolveÌýcommand, but first a few notes and reminders of what we learned in the introductory labs:
MathematicaÌýhas three different versions of the equals sign that we usually don't bother to distinguish between when writing them on paper:
"=", the single equals sign. This is used when you want to move a value into a variable so that the variable has that value throughout the rest of your session. e.g.Ìýu=7Ìýmeans that the next timeÌýuÌýis used in the session, 7 is used in its place.
":=", the colon equals. This can be thought of as "delayed assignment". e.g.Ìýv:=wÌýmeans that no value is immediately moved intoÌýv, but instead a "pointer" toÌýwÌýis established. The next timeÌývÌýis used in the session, the current value ofÌýwÌýat that timeÌýis used in its place.
"==", the double equals sign. This is used as a logical operator comparing both sides of the equality to decide on whether the statement is true or false. e.g.Ìýa+b==5Ìýwould returnÌýTrueÌýifÌýaÌýwere 2 andÌýbÌýwere 3, andÌýFalseÌýifÌýaÌýwere 8 andÌýbÌýwere 6. This form of equals sign is used when forming equations, including differential equations.
The sine function takes the formÌýSin[...], and the cosine function takes the formÌýCos[...], where you fill in the dots with the appropriate argument.
The numberÌýeÌýis referred to asÌýEÌýinÌýMathematica.
It's been a while now since we asked for the syntax of theÌýDSolveÌýcommand, so I'll just remind you.Ìý?DSolveÌýreturned the information "DSolve[eqn, y[x], x]" (among other things.)
Armed with all of the above information we should feel comfortable solving:
by entering the following command:
(Note the double equals sign, which is used since we're entering anÌýequationÌýas the first argument of the command.)
Go ahead and do so now by switching toÌýMathematica, typing it out and hitting [ENTER]. Don't be shocked by the error message, and come back here to your browser when you're done.
We nowÌýmove onÌýto discuss the message you were just assaulted with...