Flow Lab

Syllabus / Module 3: First-Order ODEs

Lesson 3.6

Exact Equations & Substitutions

Exact equations and potential functions, integrating factors for non-exact equations, Bernoulli and homogeneous substitutions.

Written byClaude Sonnet

🌊
Why this matters for simulation: Exact equations are conservative fields in disguise — the same math as stream functions in 2D flow.

By the end of this lesson you can…

  • Test M dx + N dy = 0 for exactness with M_y = N_x, and say why that is the curl-free test from Module 2.
  • Find the potential φ by integrating M in x and fixing the leftover function of y, and state where φ = C defines a function.
  • Show that the streamline equation of a 2D flow is exact exactly when the flow is incompressible, with the stream function as potential.
  • Derive when an integrating factor μ(x) or μ(y) exists, and recover the factor of lesson 3.4 as the case N = 1.
  • Solve homogeneous, Bernoulli and (given one solution) Riccati equations by substitution, naming the solutions each one loses.
  • Choose a method for a first-order equation and say honestly when none applies.
On this page
·
  1. Differential form, and what “exact” means
  2. Finding the potential, slowly
  3. The fluids connection: exactness is incompressibility
  4. The catch: potentials need simply connected regions
  5. Integrating factors for exactness
  6. Homogeneous equations: self-similar slopes
  7. Bernoulli: dividing away the nonlinearity
  8. Riccati: one known solution is enough
  9. A decision procedure, and where it ends
  10. Exercise: a numerical exactness toolkit
  11. Problems
  12. Key Takeaways

Separation (3.3 Separable Equations) handles a right side that factors, and the integrating factor (3.4 Linear First-Order Equations & Integrating Factors) handles y′+p(t)y=g(t)y' + p(t)y = g(t). This lesson adds two ideas of a different kind. Exactness: some equations say that a function of two variables stays constant, so the solution curves are its level curves. You have met that structure already, in 2.3 Gradient & Directional Derivatives and 2.9 Line Integrals, Circulation & Flux. And the change of variable: an unfamiliar equation becomes a familiar one after you rename the unknown.

It also repays a promise of the course. Streamlines of a 2D flow are solution curves of an ODE, and whether that ODE is exact is the same question as whether the flow is incompressible.

▶ Video Exact equations as level curves of a potential, the stream function, integrating factors, and the substitutions that reduce equations to ones you can already solvecaptions only
Transcript
  1. Two ideas finish the toolbox. Exactness: some equations say that a function of two variables stays constant. Substitution: rename the unknown, and a strange equation becomes one you can solve. The first is Module 2, in disguise.
  2. Write the equation as M dx plus N dy equals zero. Take M equals y and N equals x. That pair is the gradient field of Module 2, for phi equals x y. Solution curves follow the direction field, and are also level curves of phi, crossing the gradient arrows at right angles.
  3. A real example. Test it: differentiate M in y, and N in x. Both give cosine x plus two x e to the y. They match. Now build phi: integrate M in x. The constant of integration is not a number. It is an unknown function of y.
  4. Differentiate phi in y and compare with N. A leftover appears: g prime must be minus one, so g is minus y. Through one, zero, phi equals one. N there is 0.8415, not zero, so the curve is a graph, and at x equals 1.5 it sits near minus 0.813.
  5. Most equations fail the test. Here the two derivatives differ by x plus y. But that gap divided by N is one over x, a function of x alone. So multiply the whole equation by mu equals x, and the gap becomes zero.
  6. A gradient has zero integral around any closed loop. Around this circle the original gives minus 1.5708, so no potential. Multiplied by x, it gives zero. Now phi is x cubed y plus half x squared y squared, three halves through one, one, and y at two is 0.17945.
  7. A homogeneous equation has a slope that depends only on y over x. Along any ray from the origin that ratio is fixed, so the slope is fixed: three rays, three constant slopes. Scale a solution about the origin and you get another solution, dashed.
  8. Set v equals y over x. Then the equation becomes x v prime equals one over v, which is separable. Through one, one, y equals x root one plus two log x. It ends at x equals 0.6065, where the slope goes vertical. At two it is 3.0895.
  9. Bernoulli: y prime plus y over t equals t y squared. Let v equal one over y. Then v prime is minus y prime over y squared, and the nonlinear term collapses. What remains is linear: v prime minus v over t equals minus t. The solution is v equals t times three minus t.
  10. One situation, two curves. v is a parabola; y is its reciprocal. Where v reaches zero, at t equals three, y explodes: at 2.9, v is 0.29 and y is 3.4483. Starting at one half, y is back at one half at t equals two.
  11. Riccati: y prime equals two over t squared minus y squared. Knowing one solution, two over t, put y equals that plus v. That is Bernoulli, and one over v makes it linear. For y of one equal three, y is 1.4933 at 1.5, and going backward it blows up at t equals 0.630.
  12. Now fluids. A streamline of a flow u, v obeys minus v dx plus u dy equals zero. That is exact exactly when u x plus v y is zero: an incompressible flow. The potential is the stream function. For stagnation flow it is x y, the same hyperbolas as before.
  13. A point source, x, y over r squared, is incompressible away from the origin, and its stream function is the angle. But once around the origin the angle gains two pi, 6.2832: no single-valued potential. Curl-free flow has a velocity potential. Divergence-free flow has a stream function.
  14. So choose a method. Separable? Linear? Exact? Exact after a factor? A known shape that a substitution cracks? If none, there is no closed form. Most first-order equations have none, which is why the numerical methods matter.

Differential form, and what “exact” means

Write y′=−M/Ny' = -M/N as

M(x,y) dx+N(x,y) dy=0.M(x,y)\,dx + N(x,y)\,dy = 0 .

The form treats xx and yy symmetrically, so it still makes sense where N=0N = 0 and the slope is infinite. A solution is a curve whose tangent is (N,−M)(N, -M) up to scale. Call the equation exact if some φ\varphi has φx=M\varphi_x = M and φy=N\varphi_y = N, so that M dx+N dy=dφM\,dx + N\,dy = d\varphi. Then φ\varphi is constant along a solution: the solution curves are the level curves φ(x,y)=C\varphi(x,y) = C. This is the picture from the gradient lesson. The vector (M,N)=∇φ(M, N) = \nabla\varphi is perpendicular to the level curve, and the solution’s tangent satisfies (M,N)⋅(dx,dy)=0(M,N)\cdot(dx,dy) = 0, so it is perpendicular to the gradient, i.e. tangent to the level curve.

A quick test: if φ\varphi exists, then My=φxy=φyx=NxM_y = \varphi_{xy} = \varphi_{yx} = N_x by equality of mixed partials (2.1 Functions of Several Variables & Partial Derivatives). So My=Nx\boxed{M_y = N_x} is necessary. It is exactly the curl-free test of 2.9 Line Integrals, Circulation & Flux, with P=MP = M and Q=NQ = N. In Module 2 vocabulary, the equation is exact when (M,N)(M, N) is a conservative field, φ\varphi is its potential, and the test is that its 2D curl vanishes. The Module 2 caveat carries over: the test gives a potential on a simply connected region, one without holes.

Finding the potential, slowly

Worked example. Solve (ycos⁡x+2xey) dx+(sin⁡x+x2ey−1) dy=0\big(y\cos x + 2x e^{y}\big)\,dx + \big(\sin x + x^2 e^{y} - 1\big)\,dy = 0 with y(1)=0y(1) = 0.

Test. My=cos⁡x+2xey=NxM_y = \cos x + 2xe^{y} = N_x. Exact.

Step 1: integrate MM in xx, holding yy fixed.

φ=ysin⁡x+x2ey+g(y).\varphi = y\sin x + x^2 e^{y} + g(y).

The “constant” of integration is a function of yy, not a number: differentiating in xx kills anything depending on yy alone, so gg is invisible to φx=M\varphi_x = M. This is where learners slip: write +C+C and step 2 cannot work.

Step 2: differentiate in yy and match NN. φy=sin⁡x+x2ey+g′(y)\varphi_y = \sin x + x^2 e^{y} + g'(y) must equal sin⁡x+x2ey−1\sin x + x^2 e^{y} - 1. Every xx cancels, leaving g′=−1g' = -1. That cancellation is the exactness test happening a second time: if an xx survived, g′g' could not be a function of yy and the equation would not be exact. So g=−yg = -y.

Step 3. φ=ysin⁡x+x2ey−y\varphi = y\sin x + x^2 e^{y} - y, and φ(1,0)=1\varphi(1, 0) = 1 gives the solution ysin⁡x+x2ey−y=1y\sin x + x^2 e^{y} - y = 1. Check: φx=ycos⁡x+2xey=M\varphi_x = y\cos x + 2xe^y = M and φy=N\varphi_y = N.

This is an implicit solution, not solvable for yy in elementary functions. It defines y(x)y(x) where φy=N≠0\varphi_y = N \neq 0 (implicit function theorem); at the start N(1,0)=sin⁡1=0.8415N(1,0) = \sin 1 = 0.8415, so there is a unique branch through (1,0)(1,0), and it can only end where N=0N = 0, where the curve turns vertical. Marching y′=−M/Ny' = -M/N with RK4 from (1,0)(1,0) to x=1.5x = 1.5 gives y=−0.81296879y = -0.81296879, and φ\varphi there equals 11 to within 8×10−128\times 10^{-12}: the level curve and the solution curve are the same curve.

◆ Interactive Tangent directions, level curves of the potential, and the solution through a seed

Loading simulation…

Things to try, each confirmed by the readout:

  • Textbook exact equation. Drag the seed. The solution curve lies on the highlighted level curve, My−NxM_y - N_x reads 00, and the potential does not change along the curve.
  • Non-exact, (3xy+y2) dx+(x2+xy) dy=0(3xy + y^2)\,dx + (x^2 + xy)\,dy = 0. At the seed (1,1)(1,1), My−Nx=2=x+yM_y - N_x = 2 = x + y. The faint curves are only ∫M dx\int M\,dx: the highlighted one parts company with the solution, and that function changes along the solution by −4.8721-4.8721. The loop integral around the circle at (1,1)(1,1) of radius 0.50.5 is −1.5708-1.5708: no potential.
  • Tick multiply by the integrating factor. Now My−Nx=0M_y - N_x = 0, the curves brighten and the highlighted one agrees with the solution, and the loop integral is 00. Same tangents, same solutions, but a potential exists.
  • Point source flow. My−NxM_y - N_x is 00 at every seed, yet the loop integral around the origin is 6.2832=2π6.2832 = 2\pi. See below.

The fluids connection: exactness is incompressibility

A streamline of a 2D flow (u,v)(u, v) is tangent to the velocity: dy/dx=v/udy/dx = v/u, or −v dx+u dy=0-v\,dx + u\,dy = 0. That is M dx+N dy=0M\,dx + N\,dy = 0 with M=−vM = -v and N=uN = u (the sign is chosen so the potential below is the stream function with its usual sign). The exactness test My=NxM_y = N_x reads −vy=ux-v_y = u_x, that is

ux+vy=0,u_x + v_y = 0 ,

the divergence of 2.7 Divergence: Sources & Sinks. So the streamline equation is exact exactly when the flow is incompressible, and the potential ψ\psi, with ψx=−v\psi_x = -v and ψy=u\psi_y = u, is the stream function. The streamlines are its level curves.

Two potentials appear in 2D fluid mechanics, and they answer different questions:

Property of the flowTestPotentialLevel curves
curl-freevx−uy=0v_x - u_y = 0velocity potential Φ\Phi, (u,v)=∇Φ(u,v) = \nabla\Phiequipotentials
divergence-freeux+vy=0u_x + v_y = 0stream function ψ\psi, (u,v)=(ψy,−ψx)(u,v) = (\psi_y, -\psi_x)streamlines

The first is the conservative-field story of Module 2; the second is this lesson’s exact equation. The field that is conservative here is (−v,u)(-v, u), the velocity turned a quarter turn, not (u,v)(u,v) itself.

Worked example: stagnation-point flow. Let (u,v)=(x,−y)(u, v) = (x, -y). Then ux+vy=1−1=0u_x + v_y = 1 - 1 = 0. From ψy=u=x\psi_y = u = x: ψ=xy+g(x)\psi = xy + g(x). Then ψx=y+g′\psi_x = y + g' must equal −v=y-v = y, so g′=0g' = 0 and ψ=xy\psi = xy. The streamlines are the hyperbolas xy=Cxy = C, and C=0C = 0 gives the axes. A particle obeys x′=xx' = x, y′=−yy' = -y, so x=x0esx = x_0e^{s}, y=y0e−sy = y_0e^{-s}; RK4 from (0.5,2)(0.5, 2) to s=1.3s = 1.3 returns xy=1.0000000xy = 1.0000000, the starting value. The differential form earns its keep: as an ODE for y(x)y(x) this is y′=−y/xy' = -y/x, meaningless on the yy-axis, yet the streamline there is perfectly ordinary, and y dx+x dy=0y\,dx + x\,dy = 0 has no trouble.

This flow is also curl-free (vx−uy=0v_x - u_y = 0), with Φ=(x2−y2)/2\Phi = (x^2 - y^2)/2. Then ∇ψ=(y,x)\nabla\psi = (y, x) and ∇Φ=(x,−y)\nabla\Phi = (x, -y) have dot product xy−xy=0xy - xy = 0: streamlines cross equipotentials at right angles.

✅ Concept check

A 2D flow has $u = x^2$. Which choice of $v$ makes the streamline equation $-v\,dx + u\,dy = 0$ exact?

The catch: potentials need simply connected regions

Exactness is local; a global potential can fail. Take a point source, (u,v)=(x,y)/r2(u, v) = (x, y)/r^2 with r2=x2+y2r^2 = x^2 + y^2, so M=−y/r2M = -y/r^2 and N=x/r2N = x/r^2. Then My=(y2−x2)/r4=NxM_y = (y^2 - x^2)/r^4 = N_x on the whole punctured plane. The only candidate for ψ\psi is the polar angle θ=atan2⁡(y,x)\theta = \operatorname{atan2}(y, x) (check: θy=x/r2=N\theta_y = x/r^2 = N, θx=−y/r2=M\theta_x = -y/r^2 = M), whose level curves are the rays. But θ\theta is not single-valued: once around the origin adds 2π2\pi. Indeed, on the unit circle

∮M dx+N dy=∫02π(sin⁡2t+cos⁡2t) dt=2π≠0.\oint M\,dx + N\,dy = \int_0^{2\pi} (\sin^2 t + \cos^2 t)\,dt = 2\pi \neq 0 .

This is the point vortex of 2.9 Line Integrals, Circulation & Flux with the roles swapped: there θ\theta was the velocity potential of a curl-free field with a hole, here it is the stream function of a divergence-free field with a hole. The fix is the same: on any region that does not surround the origin, a continuous branch of atan2⁡\operatorname{atan2} is a fine potential. The 2π2\pi is the flux out of the source, which is why ψ\psi jumps by the source strength as you circle it.

✅ Concept check

For the source flow, $M_y = N_x$ everywhere except the origin, yet there is no single-valued potential on the punctured plane. What does that show?

Integrating factors for exactness

Most equations fail the test. For (3xy+y2) dx+(x2+xy) dy=0(3xy + y^2)\,dx + (x^2 + xy)\,dy = 0, My=3x+2yM_y = 3x + 2y and Nx=2x+yN_x = 2x + y, a gap of x+yx + y. But multiplying by a nonzero μ(x,y)\mu(x,y) does not change the solution curves, since the tangent (μN,−μM)(\mu N, -\mu M) points the same way. It does change exactness. We want

(μM)y=(μN)x  ⟺  μyM+μMy=μxN+μNx,(\mu M)_y = (\mu N)_x \iff \mu_y M + \mu M_y = \mu_x N + \mu N_x ,

a PDE for μ\mu in general. If we ask for μ\mu to depend on one variable, it collapses to an ODE.

A factor μ(x)\mu(x). With μy=0\mu_y = 0 the condition is μMy=μ′N+μNx\mu M_y = \mu' N + \mu N_x, so μ′/μ=(My−Nx)/N\mu'/\mu = (M_y - N_x)/N. The left side depends on xx alone, so such a μ\mu exists only if the right side does; if yy appears, no μ(x)\mu(x) works. When it holds, the equation is separable and μ=exp⁡∫My−NxN dx\mu = \exp\int \frac{M_y - N_x}{N}\,dx.

A factor μ(y)\mu(y). With μx=0\mu_x = 0 the condition is μ′M+μMy=μNx\mu' M + \mu M_y = \mu N_x, so μ′/μ=(Nx−My)/M\mu'/\mu = (N_x - M_y)/M, usable when that depends on yy alone.

The link to lesson 3.4. Write y′+p(t)y=g(t)y' + p(t)y = g(t) as (py−g) dt+1⋅dy=0(py - g)\,dt + 1\cdot dy = 0: M=py−gM = py - g, N=1N = 1, My=pM_y = p, Nt=0N_t = 0. The ratio (My−Nt)/N=p(t)(M_y - N_t)/N = p(t) depends on tt alone, so μ′/μ=p\mu'/\mu = p and μ=e∫p dt\mu = e^{\int p\,dt}. That is the factor of the last lesson, and lesson 3.4’s demand "μ′=pμ\mu' = p\mu" was this exactness condition in disguise. The potential is φ=μy−∫μg dt\varphi = \mu y - \int \mu g\,dt (check: φt=μpy−μg=μM\varphi_t = \mu p y - \mu g = \mu M, φy=μ=μN\varphi_y = \mu = \mu N), and the equation (μy)′=μg(\mu y)' = \mu g you integrated was dφ=0d\varphi = 0.

Worked example. For the equation above, My−NxN=x+yx(x+y)=1x\frac{M_y - N_x}{N} = \frac{x + y}{x(x + y)} = \frac1x (where x+y≠0x + y \neq 0), a function of xx alone. So μ=x\mu = x, and (3x2y+xy2) dx+(x3+x2y) dy=0(3x^2y + xy^2)\,dx + (x^3 + x^2y)\,dy = 0 is exact: both cross-partials equal 3x2+2xy3x^2 + 2xy. Integrate in xx: φ=x3y+12x2y2+g(y)\varphi = x^3y + \tfrac12x^2y^2 + g(y); φy=x3+x2y+g′\varphi_y = x^3 + x^2y + g' matches μN\mu N with g′=0g' = 0. The solutions are x3y+12x2y2=Cx^3 y + \tfrac12 x^2y^2 = C. With y(1)=1y(1) = 1, C=32C = \tfrac32; at x=2x = 2 this is 2y2+8y=322y^2 + 8y = \tfrac32, so y=(−8+76)/4=0.17945y = (-8 + \sqrt{76})/4 = 0.17945. RK4 on y′=−M/Ny' = -M/N gives 0.179449470.17944947, and the potential changes by 8×10−128\times 10^{-12} along the way, against −1.36-1.36 for the naive ∫M dx\int M\,dx.

Solutions can appear. The curve μ=0\mu = 0 solves the new equation automatically, so check it against the original. Here x=0x = 0 has dx=0dx = 0 and N=0N = 0, so it does satisfy the original form; in general it need not.

Homogeneous equations: self-similar slopes

An equation y′=F(y/x)y' = F(y/x) is called homogeneous (unrelated to “homogeneous linear” in lesson 3.4). The slope depends only on the ratio y/xy/x, so it is the same along every ray from the origin, and scaling (x,y)→(λx,λy)(x, y) \to (\lambda x, \lambda y) maps solutions to solutions. The variable that captures this is v=y/xv = y/x. Put y=xvy = xv, so y′=v+xv′y' = v + xv' and the equation becomes xv′=F(v)−vxv' = F(v) - v, that is

dvF(v)−v=dxx.\frac{dv}{F(v) - v} = \frac{dx}{x} .

It is separable, and lesson 3.3 Separable Equations finishes it. The fine print: v=y/xv = y/x needs x≠0x \neq 0, and dividing by F(v)−vF(v) - v loses any constant v∗v^* with F(v∗)=v∗F(v^*) = v^*, the straight lines y=v∗xy = v^*x.

Worked example. y′=x2+y2xyy' = \dfrac{x^2 + y^2}{xy}, y(1)=1y(1) = 1. Dividing by x2x^2, F(v)=1v+vF(v) = \frac1v + v, so xv′=1vxv' = \frac1v, v dv=dx/xv\,dv = dx/x, and 12v2=ln⁡∣x∣+c\tfrac12v^2 = \ln|x| + c. Then y2=2x2(ln⁡∣x∣+c)y^2 = 2x^2(\ln|x| + c); y(1)=1y(1) = 1 gives c=12c = \tfrac12, and on the branch y>0y \gt 0, x>0x \gt 0,

y=x1+2ln⁡x.y = x\sqrt{1 + 2\ln x} .

It exists only while 1+2ln⁡x>01 + 2\ln x \gt 0, i.e. x>e−1/2=0.6065x \gt e^{-1/2} = 0.6065. There y→0y \to 0, where the right side of the ODE is infinite: the curve has a vertical tangent and the equation gives out. Nothing is lost, since F(v)=vF(v) = v would need 1/v=01/v = 0. Check: y(2)=21+2ln⁡2=3.089527y(2) = 2\sqrt{1 + 2\ln 2} = 3.089527, and RK4 gives 3.0895273.089527.

Two routes, one answer. The equation (3xy+y2) dx+(x2+xy) dy=0(3xy + y^2)\,dx + (x^2 + xy)\,dy = 0 is homogeneous too: y′=−(3v+v2)/(1+v)y' = -(3v + v^2)/(1 + v), so xv′=−2v(v+2)/(1+v)xv' = -2v(v+2)/(1+v). Since 1+vv(v+2)=12v+12(v+2)\frac{1+v}{v(v+2)} = \frac{1}{2v} + \frac{1}{2(v+2)}, we get 12ln⁡∣v(v+2)∣=−2ln⁡∣x∣+c\tfrac12\ln|v(v+2)| = -2\ln|x| + c, which simplifies to x2y2+2x3y=Cx^2y^2 + 2x^3y = C: twice the potential found with μ=x\mu = x. The lines y=0y = 0 and y=−2xy = -2x lost to the division sit inside the family at C=0C = 0.

Bernoulli: dividing away the nonlinearity

A Bernoulli equation is y′+p(t)y=q(t)yny' + p(t)y = q(t)y^{n} with n≠0,1n \neq 0, 1 (those are linear already). Divide by yny^n:

y−ny′+p y1−n=q.y^{-n}y' + p\,y^{1-n} = q .

Since ddty1−n=(1−n) y−ny′\frac{d}{dt}y^{1-n} = (1-n)\,y^{-n}y', the derivative term is a multiple of v′v' for v=y1−nv = y^{1-n}, and the other appearance of yy is vv itself. So v′1−n+pv=q\frac{v'}{1-n} + pv = q, that is

v′+(1−n) p v=(1−n) q,v' + (1-n)\,p\,v = (1-n)\,q ,

linear in vv, so lesson 3.4 Linear First-Order Equations & Integrating Factors applies, and then y=v1/(1−n)y = v^{1/(1-n)}. The fine print: dividing by yny^n assumed y≠0y \neq 0, and for n>0n \gt 0 the function y≡0y \equiv 0 solves the original equation but is never produced by the formula.

Worked example. y′+yt=ty2y' + \dfrac{y}{t} = ty^2, y(1)=12y(1) = \tfrac12, t>0t \gt 0. Here n=2n = 2 and v=1/yv = 1/y:

v′=−y′y2=−−y/t+ty2y2=1ty−t=vt−t.v' = -\frac{y'}{y^2} = -\frac{-y/t + ty^2}{y^2} = \frac{1}{ty} - t = \frac vt - t .

So v′−v/t=−tv' - v/t = -t. With μ=1/t\mu = 1/t, (v/t)′=−1(v/t)' = -1, so v=Ct−t2v = Ct - t^2 and y=1/(Ct−t2)y = 1/(Ct - t^2). Then y(1)=12y(1) = \tfrac12 gives C=3C = 3:

y=1t(3−t),0<t<3.y = \frac{1}{t(3 - t)}, \qquad 0 \lt t \lt 3 .

RK4 gives y(2.5)=0.80000000y(2.5) = 0.80000000 (formula: 1/(2.5⋅0.5)1/(2.5\cdot 0.5)) and y(2.9)=3.44827586y(2.9) = 3.44827586 (1/(2.9⋅0.1)1/(2.9 \cdot 0.1)). The blow-up has a mechanism: v=3t−t2v = 3t - t^2 solves a linear equation and is finite everywhere, but y=1/vy = 1/v explodes where vv crosses zero, at t=3t = 3. A nonlinear equation can run away in finite time while being a linear one in disguise. The lost solution is y≡0y \equiv 0 (it satisfies 0+0=00 + 0 = 0, and 1/(Ct−t2)1/(Ct - t^2) is never 00).

A second check: the logistic equation y′=y(1−y)y' = y(1-y) is Bernoulli with n=2n = 2. With v=1/yv = 1/y, v′=−(1−y)/y=1−vv' = -(1-y)/y = 1 - v, so v=1+Ce−tv = 1 + Ce^{-t} and y=1/(1+Ce−t)y = 1/(1 + Ce^{-t}): the family quoted in lesson 3.1 What Is a Differential Equation?, with y=0y = 0 again the member it misses.

Riccati: one known solution is enough

The Riccati equation y′=q0(t)+q1(t)y+q2(t)y2y' = q_0(t) + q_1(t)y + q_2(t)y^2 has no closed form in general. But given one solution y1y_1, put y=y1+vy = y_1 + v and subtract the equation for y1y_1 (the q0q_0 terms cancel):

v′=q1v+q2[(y1+v)2−y12]=(q1+2q2y1) v+q2 v2,v' = q_1 v + q_2\big[(y_1 + v)^2 - y_1^2\big] = (q_1 + 2q_2y_1)\,v + q_2\,v^2 ,

a Bernoulli equation with n=2n = 2.

Worked example. y′=2/t2−y2y' = 2/t^2 - y^2. Try y1=2/ty_1 = 2/t: y1′=−2/t2y_1' = -2/t^2 and 2/t2−4/t2=−2/t22/t^2 - 4/t^2 = -2/t^2. (Finding it was a guess from the scaling; no method promises one.) With q1=0q_1 = 0, q2=−1q_2 = -1: v′=−4tv−v2v' = -\frac4tv - v^2. Set w=1/vw = 1/v: w′=−v′/v2=4tw+1w' = -v'/v^2 = \frac4tw + 1. With factor t−4t^{-4}, (t−4w)′=t−4(t^{-4}w)' = t^{-4}, so w=Ct4−t/3w = Ct^4 - t/3 and

y=2t+1Ct4−t/3.y = \frac2t + \frac{1}{Ct^4 - t/3} .

For y(1)=3y(1) = 3, C=43C = \tfrac43 and y=2t+34t4−ty = \frac2t + \frac{3}{4t^4 - t}. RK4 gives y(1.5)=1.49333333y(1.5) = 1.49333333 and y(2)=1.04838710y(2) = 1.04838710, matching the formula. Going backwards it blows up at t=(1/4)1/3=0.630t = (1/4)^{1/3} = 0.630. The known solution y1y_1 itself is lost (v=0v = 0), while C=0C = 0 gives y=−1/ty = -1/t, which checks directly: y′=1/t2=2/t2−1/t2y' = 1/t^2 = 2/t^2 - 1/t^2.

A decision procedure, and where it ends

Each technique answers “what is this equation secretly?” Try them in order of cost:

  1. Separable? y′=f(t)g(y)y' = f(t)g(y): separate and integrate (3.3 Separable Equations).
  2. Linear? y′+py=gy' + py = g: use μ=e∫p\mu = e^{\int p} (3.4 Linear First-Order Equations & Integrating Factors).
  3. Exact? Write M dx+N dy=0M\,dx + N\,dy = 0 and test My=NxM_y = N_x.
  4. Exact after a factor? If (My−Nx)/N(M_y - N_x)/N depends on xx only, or (Nx−My)/M(N_x - M_y)/M on yy only, you have μ\mu.
  5. A recognizable shape? y′=F(y/x)y' = F(y/x) gets v=y/xv = y/x; y′+py=qyny' + py = qy^n gets v=y1−nv = y^{1-n}; a Riccati with a known solution gets y=y1+vy = y_1 + v.

Every substitution has one recipe: choose vv so its derivative eats the troublesome part, solve, translate back, and ask what was lost.

After step 5 the honest answer is: usually nothing, in closed form. The innocent-looking y′=t2+y2y' = t^2 + y^2 is Riccati and has no elementary solution, and equations from practice (drag laws, reaction rates, lookup tables) rarely have even that much structure. That is why Euler, RK4 and RK45 are the main tool, not the fallback. Closed forms stay useful in two ways. They are answer keys for a solver. And a conserved potential is an error monitor: for the exact equation above, φ\varphi is exactly constant along true solutions, so its drift along a numerical solution measures the error without needing the answer. The cell below shows Euler with 100 steps drifting by −2.5×10−3-2.5\times 10^{-3} while RK4 drifts by 8×10−128\times 10^{-12}.

🐍 PythonPlayground: test exactness, apply a factor, and watch a conserved quantity as an error monitor
⌘/Ctrl + Enter

Exercise: a numerical exactness toolkit

The tests an equation needs, the factor rule, and the conserved quantity are all computable without symbolic algebra. Implement them for any MM and NN given as Python functions, and check them against each other.

🧪 Coding exerciseExercise: exactness gap, factor ratio, streamline, and drift of the potential
⌘/Ctrl + Enter

Problems

✏️ Pen & paperExact, with an end to the solution●○○

Solve (3x2+2xy) dx+(x2+2y) dy=0(3x^2 + 2xy)\,dx + (x^2 + 2y)\,dy = 0, y(0)=2y(0) = 2. Find φ\varphi, solve φ=C\varphi = C for yy, and say over what interval of xx the solution exists and what happens at its end.

Show worked solution

My=2x=NxM_y = 2x = N_x. Integrate MM: φ=x3+x2y+g(y)\varphi = x^3 + x^2y + g(y), and φy=x2+g′=x2+2y\varphi_y = x^2 + g' = x^2 + 2y gives g=y2g = y^2. So φ=x3+x2y+y2\varphi = x^3 + x^2y + y^2, and φ(0,2)=4\varphi(0,2) = 4. As a quadratic in yy,

y=−x2+x4−4x3+162,y = \frac{-x^2 + \sqrt{x^4 - 4x^3 + 16}}{2},

with the plus sign so that y(0)=2y(0) = 2. The radicand is (x−2)(x3−2x2−4x−8)(x-2)(x^3 - 2x^2 - 4x - 8); for x<2x \lt 2 both factors are negative, so it is positive and the branch exists for every x<2x \lt 2. At x=2x = 2 the radicand is 00 and y=−2y = -2, where N=4−4=0N = 4 - 4 = 0: the tangent is vertical and the curve turns back along the other branch, so the solution ends there. Check: the formula gives y(1)=1.30277564y(1) = 1.30277564 and y(−1)=1.79128785y(-1) = 1.79128785, both matched by RK4 on y′=−M/Ny' = -M/N from (0,2)(0,2).

✏️ Pen & paperAn integrating factor in y●●○

For y dx+(2x−yey) dy=0y\,dx + (2x - ye^{y})\,dy = 0: (a) show it is not exact and decide whether μ(x)\mu(x) or μ(y)\mu(y) can work; (b) find the implicit solution; (c) the factor vanishes on y=0y = 0: is y=0y = 0 a solution of the original, and where is it in your family?

Show worked solution

(a) My=1≠2=NxM_y = 1 \neq 2 = N_x. The ratio (My−Nx)/N=−1/(2x−yey)(M_y - N_x)/N = -1/(2x - ye^y) involves yy, so no μ(x)\mu(x). But (Nx−My)/M=1/y(N_x - M_y)/M = 1/y depends on yy alone, so μ′/μ=1/y\mu'/\mu = 1/y and μ=y\mu = y. Check: (y2)y=2y=(y(2x−yey))x(y^2)_y = 2y = \big(y(2x - ye^y)\big)_x.

(b) Integrate y2y^2 in xx: φ=xy2+g(y)\varphi = xy^2 + g(y). Then φy=2xy+g′=2xy−y2ey\varphi_y = 2xy + g' = 2xy - y^2e^y gives g′=−y2eyg' = -y^2e^y, so g=−ey(y2−2y+2)g = -e^y(y^2 - 2y + 2) (differentiate to check). The solutions are xy2−ey(y2−2y+2)=Cxy^2 - e^y(y^2 - 2y + 2) = C.

(c) On y=0y = 0, dy=0dy = 0 and the original reads 0=00 = 0, so yes, it is a solution of the original. It lies in the family at C=φ(x,0)=−2C = \varphi(x, 0) = -2.

✏️ Pen & paperA Bernoulli equation with a square root●●●

Consider y′+2y=3yy' + 2y = 3\sqrt y. (a) Find nn, substitute v=y1−nv = y^{1-n}, and solve. (b) Solve y(0)=4y(0) = 4 and find where yy settles. (c) For y(0)=0y(0) = 0 find two solutions, and say why the uniqueness theorem does not apply.

Show worked solution

(a) n=12n = \tfrac12, v=yv = \sqrt y. Dividing by y\sqrt y: y−1/2y′+2y=3y^{-1/2}y' + 2\sqrt y = 3, and y−1/2y′=2v′y^{-1/2}y' = 2v', so 2v′+2v=32v' + 2v = 3 and v=32+Ce−tv = \tfrac32 + Ce^{-t}. Then y=v2y = v^2, valid only while v≥0v \geq 0 (because y=∣v∣\sqrt y = |v| equals vv only then).

(b) v(0)=2v(0) = 2, so y=(32+12e−t)2y = \big(\tfrac32 + \tfrac12e^{-t}\big)^2, positive throughout. Check: y(1)=2.83565298y(1) = 2.83565298, matching RK4. As t→∞t \to \infty, y→94y \to \tfrac94, where 2y=3y2y = 3\sqrt y.

(c) y≡0y \equiv 0 works, and so does v=32(1−e−t)≥0v = \tfrac32(1 - e^{-t}) \geq 0, i.e. y=94(1−e−t)2y = \tfrac94(1 - e^{-t})^2. The uniqueness theorem needs the right side to be Lipschitz in yy, and y\sqrt y has infinite slope at 00, so solutions may leave y=0y = 0 whenever they like. A solver started exactly at 00 sees slope 00 and never finds the second one.

✏️ Pen & paperA saddle flow●●○

A flow has u=2x+yu = 2x + y, v=x−2yv = x - 2y. (a) Show it is incompressible and find ψ\psi. (b) Show it is curl-free and find Φ\Phi. (c) Check at (1,0)(1,0) that ∇Φ⊥∇ψ\nabla\Phi \perp \nabla\psi and find the streamline through (1,0)(1,0).

Show worked solution

(a) ux+vy=2−2=0u_x + v_y = 2 - 2 = 0. With M=−v=−x+2yM = -v = -x + 2y, N=u=2x+yN = u = 2x + y: ψ=−12x2+2xy+g(y)\psi = -\tfrac12x^2 + 2xy + g(y), and ψy=2x+g′=2x+y\psi_y = 2x + g' = 2x + y gives g=12y2g = \tfrac12y^2. So ψ=2xy+12y2−12x2\psi = 2xy + \tfrac12y^2 - \tfrac12x^2. Check: ψy=u\psi_y = u and −ψx=x−2y=v-\psi_x = x - 2y = v.

(b) vx−uy=1−1=0v_x - u_y = 1 - 1 = 0. From Φx=2x+y\Phi_x = 2x + y: Φ=x2+xy+h(y)\Phi = x^2 + xy + h(y), and Φy=x+h′=x−2y\Phi_y = x + h' = x - 2y gives Φ=x2+xy−y2\Phi = x^2 + xy - y^2.

(c) At (1,0)(1,0), ∇Φ=(u,v)=(2,1)\nabla\Phi = (u,v) = (2,1) and ∇ψ=(−v,u)=(−1,2)\nabla\psi = (-v, u) = (-1, 2); the dot product is 00. The streamline is ψ=ψ(1,0)=−12\psi = \psi(1,0) = -\tfrac12, i.e. x2−4xy−y2=1x^2 - 4xy - y^2 = 1. RK4 on x′=ux' = u, y′=vy' = v from (1,0)(1,0) keeps ψ=−0.5\psi = -0.5 to 10−1410^{-14} after 0.40.4 time units.

Key Takeaways

  • An equation M dx+N dy=0M\,dx + N\,dy = 0 is exact when (M,N)=∇φ(M,N) = \nabla\varphi; solutions are the level curves φ=C\varphi = C. The test My=NxM_y = N_x is the Module 2 curl-free test.
  • To find φ\varphi, integrate MM in xx and add a function of yy; differentiate in yy, match NN, and expect every xx to cancel.
  • The streamline equation is exact exactly when ux+vy=0u_x + v_y = 0 (incompressible), with the stream function as potential. Curl-free flow has a different potential, the velocity potential.
  • Exactness is local; a global potential needs a simply connected region. The source flow has My=NxM_y = N_x but loop integral 2π2\pi around its hole.
  • μ(x)\mu(x) exists when (My−Nx)/N(M_y - N_x)/N depends on xx alone, μ(y)\mu(y) when (Nx−My)/M(N_x - M_y)/M depends on yy alone; lesson 3.4’s factor is the case N=1N = 1. A factor can add the solution μ=0\mu = 0.
  • Homogeneous equations become separable (v=y/xv = y/x), Bernoulli equations linear (v=y1−nv = y^{1-n}), and a Riccati with a known solution Bernoulli. Check what each loses: x=0x = 0, y=0y = 0, the lines y=v∗xy = v^*x.
  • Implicit solutions define a function where φy≠0\varphi_y \neq 0 and end where the curve turns vertical.
  • Most first-order equations have no closed form. Closed forms are answer keys, and a conserved φ\varphi monitors a solver’s error.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.