Preface
This is a tutorial made solely for the purpose of education and it was designed for students taking Applied Math 0330. It is primarily for students who have very little experience or have never used Mathematica before and would like to learn more of the basics for this computer algebra system. As a friendly reminder, don't forget to clear variables in use and/or the kernel.
Finally, the commands in this tutorial are all written in bold black font, while Mathematica output is in normal font. This means that you can copy and paste all commands into Mathematica, change the parameters and run them. You, as the user, are free to use the scripts for your needs to learn the Mathematica program, and have the right to distribute this tutorial and refer to this tutorial as long as this tutorial is accredited appropriately.
Return to computing page for the second course APMA0340
Return to Mathematica tutorial for the second course APMA0330
Return to Mathematica tutorial for the first course APMA0340
Return to the main page for the course APMA0340
Return to the main page for the course APMA0330
Return to Part II of the course APMA0330
Exact Equations
Recall the total differential of a function ψ(x,y) of two variables, denoted by dψ, is given by the expression
Let M(x,y) and N(x,y) be two smooth functions having continuous partial derivatives in some domain \( \Omega \subset \mathbb{R}^2 \) without holes. A differential equation, written in differentials
There are two approaches to find a potential function corresponding to an exact equation. The first one is based on integration of
line2 = Line[{{1, 0.5}, {1, 3}, {4, 3}}];
a = {Graphics[{Thick, Dashed, Blue, line1}], Graphics[{Thick, line2}]}
b = Graphics[Text[Style["(x,y)", FontSize -> 14, Red], {4.0, 3.2}]]
b0 = Graphics[ Text[Style["(x0,y0)", FontSize -> 14, Blue], {1.0, 0.3}]]
aa1 = Graphics[Arrow[{{1, 1}, {1, 2}}]]
aa2 = Graphics[Arrow[{{2, 3}, {3, 3}}]]
aa3 = Graphics[{Blue, Arrow[{{1, 0.5}, {3, 0.5}}]}]
aa4 = Graphics[{Blue, Arrow[{{4, 1}, {4, 2}}]}]
Show[aa1, aa2, aa3, aa4, a, b, b0, Axes -> True, AxesOrigin -> {0, 0},
PlotRange -> {{-0.5, 4.5}, {-0.5, 3.5}}, AxesLabel -> {x, y}, TicksStyle -> Directive[FontOpacity -> 0, FontSize -> 0]]

If we integrate along black line (vertically where dx = 0 and then horizontally where dy = 0), we get
Now if we integrate along blue dashed line (horizontally where dy = 0 and then vertically where dx = 0), we get
Example: The equation \( y \,\text{d}x + x \,\text{d}y =0 \) is exact because \( M_y =1 = N_x \) for \( M= y \quad\mbox{and} \quad N= x . \) Suppose that the initial condition \( y(2)=3 \) is given.
We type in Mathematica:
{p1, p2} = {2, 3};
Simplify[D[MM[x, y], y] == D[NN[x, y], x]]
Integrate[MM[x, p2], {x, p1, X}] + Integrate[NN[X, y], {y, p2, Y}]
The solution is psi[x,y]==0:
Define the gradient function:
and then check our potential function:
Example: Consider the differential equation
a=TrueQ[D[MM,y]==D[NN,x]];
If[a==True, Print["The equation is exact"], Print["The equation is not exact"]]

Solving First Order ODEs
Plotting Solutions to ODEs
Direction Fields
Separable Equations
Equations Reducible to the Separable Equations
Equations with Linear Fractions
Exact Equations
Integrating Factors
Linear Equations
RC circuits
Bernoulli Equations
Riccati Equations
Existence and Uniqueness
Qualitative Analysis
Bifurcations
Orthogonal Trajectories
Population Models
Applications
Return to Mathematica page
Return to the main page (APMA0330)
Return to the Part 1 (Plotting)
Return to the Part 2 (First Order ODEs)
Return to the Part 3 (Numerical Methods)
Return to the Part 4 (Second and Higher Order ODEs)
Return to the Part 5 (Series and Recurrences)
Return to the Part 6 (Laplace Transform)
Return to the Part 7 (Boundary Value Problems)