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

Bernoulli Equations
A differential equation
Bernoulli returned to Switzerland and began teaching mechanics at the University in Basel from 1683. In 1684 he married Judith Stupanus; and they had two children. He was appointed professor of mathematics at the University of Basel in 1687, remaining in this position for the rest of his life. By that time, he had begun tutoring his brother Johann Bernoulli on mathematical topics. The two brothers began to study the calculus as presented by Leibniz in his 1684 paper on the differential calculus. Jacob collaborated with his brother on various applications of calculus. However the atmosphere of collaboration between the two brothers turned into rivalry as Johann's own mathematical genius began to mature, with both of them attacking each other in print, and posing difficult mathematical challenges to test each other's skills. By 1697, the relationship had completely broken down.
Jacob Bernoulli is known for his numerous contributions to calculus, and along with his brother Johann, was one of the founders of the calculus of variations. In May 1690, in a paper published in Acta Eruditorum, Jacob Bernoulli showed that the problem of determining the isochrone is equivalent to solving a first-order nonlinear differential equation. The isochrone, or curve of constant descent, is the curve along which a particle will descend under gravity from any point to the bottom in exactly the same time, no matter what the starting point. He also discovered the fundamental mathematical constant e, which Euler later denoted by e.
Jacob made a great contribution to calculus. By 1689 he had published important work on infinite series and showed that harmonic series diverges, which had actually been proved by Mengoli 40 years earlier. Jacob Bernoulli also discovered a general method to determine evolutes of a curve as the envelope of its circles of curvature. He also investigated caustic curves and in particular he studied these associated curves of the parabola, the logarithmic spiral and epicycloids around 1692. The lemniscate of Bernoulli was first conceived by Jacob Bernoulli in 1694. In 1695 he investigated the drawbridge problem which seeks the curve required so that a weight sliding along the cable always keeps the drawbridge balanced.
However, his most important contribution was in the field of probability, where he derived the first version of the law of large numbers in his work Ars Conjectandi, published in Basel in 1713, eight years after his death.Jacob Bernoulli chose a figure of a logarithmic spiral (its equation in polar coordinates is \( r = a\, e^{b\,\theta} \) ) and the motto Eadem mutata resurgo ("Changed and yet the same, I rise again") for his gravestone; the spiral executed by the stonemasons was, however, an Archimedean spiral, \( r = a + b\, \theta . \)
Bernoulli equations are special because they are nonlinear differential equations with known exact solutions. Moreover, they do not have singular solutions---similar to linear equations. There are two methods known to determine its solutions: one was discovered by himself, and another is credited to Leibniz.
Leibniz substitution
The Bernoulli equation \( y' + p(x)\,y = g(x)\,y^\alpha \) can be reduced to a linear differential equation with substitution
L[x_] := D[x, t] + p*x - q*x^n;
x = y[t]^(1/(1 - n));
a2 = Simplify[L[x]];
a3 = a2/y[t]^(n/(1 - n));
Simplify[PowerExpand[a3]]
Out[36]= ConditionalExpression[
8^(n/(1 - n)) t^((2 n)/(3 - 3 n)) (7 + t^(8/3))^(
n/(-1 + n)) (p (7/(8 t^(2/3)) + t^2/8)^(1/(1 - n)) -
q (7/(8 t^(2/3)) + t^2/8)^(n/(1 - n)) - (
2 (7/(8 t^(2/3)) + t^2/8)^(1/(1 - n)) (-7 + 3 t^(8/3)))/(
3 (-1 + n) t (7 + t^(8/3)))), (Re[t] >= 0 ||
t \[NotElement] Reals) && (Re[u] >= 0 || u \[NotElement] Reals)]
Bernoulli method
The Bernoulli equation \( y' + p(x)\,y = g(x)\,y^\alpha \) can be reduced to two separable equations. We seek its solution as the product of two functions \( y(x) = u(x)\,v(x) , \) where u(x) is a solution (we need just one of them) of a linear part:Example: Consider the differential equation \( y\, y' = y^2 + e^x . \) To solve it, we first use the Leibniz substitution: \( u = y^{2} \quad \Longleftrightarrow \quad y = u^{1/2} . \) Then \( y' = \frac{1}{2}\, u^{-1/2} u' \quad \Longrightarrow \quad y\,y' = \frac{1}{2}\, u' \) and we get the linear differential equation
Now we demonstrate the application of the Bernoulli method by seeking the solution as the product y = u v, where u is a solution of the "linear part:"
Table[{Sqrt[-2 E^x + c E^(2 x)], -Sqrt[-2 E^x + c E^(2 x)]}, {c,
1/4, 3, 3/4}]] (* increment is 3/4 *)
Out[1]= {Sqrt[-2 E^x + E^(2 x)/4], -Sqrt[-2 E^x + E^(2 x)/4], Sqrt[-2 E^x +
E^(2 x)], -Sqrt[-2 E^x + E^(2 x)], Sqrt[-2 E^x + (7 E^(2 x))/
4], -Sqrt[-2 E^x + (7 E^(2 x))/4], Sqrt[-2 E^x + (5 E^(2 x))/
2], -Sqrt[-2 E^x + (5 E^(2 x))/2]}
Plot[Evaluate[curves], {x, 0, 4}, PlotRange -> All]

Example: The four streamlines (corresponding to the values of an arbitrary constant C=1,2,3,4) from the general solution y=1/(x Sqrt[C-2 ln[x]]) of the Bernoulli equation
x y' =x^2 y^3 -y can be plotted with one command:

Example: Consider the Bernoulli equation \( y' +x\,y=x\, y^4 . \) Using Leibniz substitution
BNum =4
u[x_] == y[x]^(1-BNum)
yp = Solve[u'[x] == D[y[x]^(1-BNum),x],y'[x]]
LeftSide = Map[Function[t, t/y[x]^BNum],
BerEq[x, y] /. yp[[1]] /. {(a_ == b_) -> a - b}]
L[x_, u_] = LeftSide /. {y[x]^(1 - BNum) -> u[x]}
SolU = DSolve[L[x,u] == 0,u[x],x]
Sol[x_] = Simplify[(u[x]/.SolU[[1]]^(1/(1-BNum)))]
Out[5]= u[x_] == 1/y[x]^3
Out[6]= {{Derivative[1][y][x] -> -(1/3) y[x]^4 Derivative[1][u][x]}}
Out[7]= -1 + x/y[x]^3 - Derivative[1][u][x]/3
Out[8]= -1 + x u[x] - Derivative[1][u][x]/3
Out[9]= {{u[x] ->
E^((3 x^2)/2) C[1] -
E^((3 x^2)/2) Sqrt[(3 \[Pi])/2] Erf[Sqrt[3/2] x]}}
Out[10]= u[x] /. {1/(u[x] ->
1/2 E^((3 x^2)/2) (2 C[1] - Sqrt[6 \[Pi]] Erf[Sqrt[3/2] x]))^(1/3) }
Now we find the general solution using the Bernoulli method: y = u*v, where u is a solution of the "truncated" linear equation \( u' + x\,u =0 \) and v is the general solution of the separable equation \( u\, v' = x\, \left( u\, v \right)^4 . \) Solving the equation for u, we get
u[x_] = u[x] /. First@DSolve[{u'[x] + x u[x] == 0, u[0] == 1}, u[x], x]
y[x_] == Simplify[ u[x]*v[x] /. First@DSolve[u[x]*v'[x] == x*(u[x]*v[x])^4, v[x], x]]
Example: (Logistic equation)
The logistic equation with harvesting \( \dot{y} = r\, y \left( 1 - \frac{y}{k} \right) - h\, y(t) \) is an example of the logistic equations. It is assumed that all coefficients (r, k, h) are constants. It can be solved and plotted as follows.DSolve[LogisticEquation, y, t]
{{y -> Function[{t}, -((E^(r t + h k C[1]) k (-h + r))/(
E^(h t + k r C[1]) - E^(r t + h k C[1]) r))]}}
{{y -> Function[{t}, (5 a E^(t/4))/(5 - a + a E^(t/4))]}}
To plot the results, we employ two options:
{-((25 E^(t/4))/(10 - 5 E^(t/4))), -((20 E^(t/4))/(
9 - 4 E^(t/4))), -((15 E^(t/4))/(8 - 3 E^(t/4))), -((10 E^(t/4))/(
7 - 2 E^(t/4))), -((5 E^(t/4))/(6 - E^(t/4))), 0, (5 E^(t/4))/(
4 + E^(t/4)), (10 E^(t/4))/(3 + 2 E^(t/4)), (15 E^(t/4))/(
2 + 3 E^(t/4)), (20 E^(t/4))/(1 + 4 E^(t/4)), 5}

y[t] /. sol /. {{a -> 1}, {a -> -1}, {a -> -1.5}, {a -> 1.5}}], {t, -1, 5}, PlotRange -> All]

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)