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
Equations with Linear Fractions
A wide class of differential equations of the form
If aB−Ab≠0, constants c and C can be eliminated by shifting the system of coordinates:
We start our exposition by considering equations with slope function as the ratio of two linear functions:
Example: Consider the differential equation:
We plot the corresponding direction fields using StreamPlot command:
StreamPoints -> {Tuples[Range[-1, 4, 0.2], 2], Automatic, 10},
ImageSize -> Medium, StreamStyle -> "Line"]
![]() |
![]() |
Example: Consider an algebraic equation: 2x2+y2−2xy+5x=0 and we wish to determine a differential equation to which the algebraic equation defines implicitly its solution. Mathematica is capable to find the required differential equation.
To extract the left-hand side, type:
Axes -> Automatic, AxesOrigin -> {0, 0},
AxesStyle -> GrayLevel[0.5], PlotPoints -> 100, Contours -> {0},
ContourShading -> False]

If the option

In the above graphs, the option Contour->{0} instructs Mathematica to graph only the level curve corresponding to 0.
The option
The option
Note that instead of eq[[1]], one can use the equation 5 x + 2 x^2 - 2 x y + y^2 explicitly.
Now we instruct Mathematica to find the differential equation in two steps.
Therefore, we get the differential equation
StreamPoints -> RandomReal[{-6, 0}, {#, 2}],
StreamColorFunction -> (GrayLevel[RandomReal[]] &),
ImageSize -> 500] &, ConstantArray[50, 100]];
Show[t]
xrange = {-6, 1};
yrange = {-6, 1};
xdivs = 3;
ydivs = 3;
xranges = Partition[Rescale[Range[0, xdivs], {0, xdivs}, xrange], 2, 1];
yranges = Partition[Rescale[Range[0, ydivs], {0, ydivs}, yrange], 2, 1];
Show[Flatten@
Table[StreamPlot[
f[x, y], {x, First@xr, Last@xr}, {y, First@yr, Last@yr},
StreamScale -> {0.2, Automatic, 0.01}, StreamPoints -> 100], {xr,
xranges}, {yr, yranges}], PlotRange -> All, ImageSize -> Large]
LineIntegralConvolutionScale -> 0.6,
ColorFunction -> GrayLevel, RasterSize -> 200]
![]() |
![]() |
![]() |
Example: Consider the differential equation
Now we return to the original variables. Since X=x−1, Y=y, and
v=Y/X, the original differential equation has the general solution
in implicit form:
Plot[((x - 1)*(#1 Abs[x - 1]^a *(9 - a) - 9 - a)/(#1 Abs[x - 1]^a - 1)/ 8 &) /@ {-1, 0, 1, 2, 3}, {x, -5, 10}]
![]() |
![]() |
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)