TExcelTAD
Home › Differential Equations › Substitution: Bernoulli and Homogeneous Equations

Substitution: Bernoulli and Homogeneous Equations

Many equations that are neither separable nor linear become one of the two after a change of variables. The idea is the same as substitution in integrals: pick a new unknown vv, rewrite yy and y′y' in terms of vv, and hope the new equation is easier. Three substitutions cover most textbook cases.

1. Linear combinations: y′=f(ax+by+c)y' = f(ax + by + c)

Set v=ax+by+cv = ax + by + c. Then v′=a+by′=a+bf(v)v' = a + by' = a + bf(v), which is separable.

Example. y′=(x+y)2y' = (x + y)^2. With v=x+yv = x + y: v′=1+v2v' = 1 + v^2, so arctan⁡v=x+C\arctan v = x + C and y=tan⁡(x+C)−xy = \tan(x + C) - x.

2. Homogeneous equations: y′=F(y/x)y' = F(y/x)

If the right side depends only on the ratio y/xy/x, set v=y/xv = y/x, so y=xvy = xv and y′=v+xv′y' = v + xv'. Then v+xv′=F(v)v + xv' = F(v), i.e.

x v′=F(v)−v,x\,v' = F(v) - v,

which is separable. (This use of "homogeneous" is unrelated to "homogeneous linear equation"; the name is historical.)

Example. y′=x2+y2xy=1v+vy' = \frac{x^2 + y^2}{xy} = \frac{1}{v} + v. Then xv′=1vxv' = \frac{1}{v}, so v dv=dxxv\,dv = \frac{dx}{x}, v22=ln⁡∣x∣+C\frac{v^2}{2} = \ln\lvert x\rvert + C, and y2=2x2(ln⁡∣x∣+C)y^2 = 2x^2(\ln\lvert x\rvert + C).

python · try it yourself
import sympy as sp

x = sp.symbols("x", positive=True)
y = sp.Function("y")
ode = sp.Eq(y(x).diff(x), (x**2 + y(x)**2) / (x * y(x)))
for s in sp.dsolve(ode):
    print(s)
Eq(y(x), -x*sqrt(C1 + 2*log(x)))
Eq(y(x), x*sqrt(C1 + 2*log(x)))

SymPy returns both branches of the square root.

3. Bernoulli equations: y′+p(x)y=q(x)yny' + p(x)y = q(x)y^n

For n≠0,1n \ne 0, 1 this is nonlinear, but v=y1−nv = y^{1-n} makes it linear. Since v′=(1−n)y−ny′v' = (1 - n)y^{-n}y', divide the equation by yny^n and multiply by 1−n1 - n:

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

which the integrating factor solves.

Example. y′+y=y3y' + y = y^3. Here n=3n = 3, v=y−2v = y^{-2} and v′−2v=−2v' - 2v = -2. So v=1+Ce2xv = 1 + Ce^{2x} and y=±11+Ce2xy = \pm\frac{1}{\sqrt{1 + Ce^{2x}}}.

python · try it yourself
import numpy as np
from scipy.integrate import solve_ivp

# y(0) = 0.5 -> v(0) = 4 -> C = 3
sol = solve_ivp(lambda x, y: y**3 - y, (0, 2), [0.5], t_eval=[0.5, 1, 2], rtol=1e-10, atol=1e-12)
for xv, yv in zip(sol.t, sol.y[0]):
    print(f"x = {xv}: numeric {yv:.8f}, formula {1 / np.sqrt(1 + 3 * np.exp(2 * xv)):.8f}")
x = 0.5: numeric 0.33050230, formula 0.33050230
x = 1.0: numeric 0.20776076, formula 0.20776076
x = 2.0: numeric 0.07789843, formula 0.07789843

Which substitution?

Shape of the equation Substitution Result
y′=f(ax+by+c)y' = f(ax + by + c) v=ax+by+cv = ax + by + c separable
y′=F(y/x)y' = F(y/x) v=y/xv = y/x separable
y′+py=qyny' + py = qy^n v=y1−nv = y^{1-n} linear
y′=f(x)g(y)y' = f(x)g(y) none needed separable

sp.classify_ode tells you which forms SymPy recognises. Names such as Bernoulli and 1st_homogeneous_coeff_subs_dep_div_indep correspond to rows of this table, but SymPy may also pick a different route: below, it notices that y′+y=y3y' + y = y^3 is separable as well as Bernoulli, and it treats y′=(x+y)2y' = (x + y)^2 as a Riccati equation rather than using our substitution. Several methods often solve the same equation.

python · try it yourself
import sympy as sp

x = sp.symbols("x")
y = sp.Function("y")
for ode in (sp.Eq(y(x).diff(x) + y(x), y(x)**3),
            sp.Eq(y(x).diff(x), (x + y(x))**2)):
    print([h for h in sp.classify_ode(ode) if "Integral" not in h][:4])
['separable', '1st_exact', 'Bernoulli', '1st_power_series']
['factorable', '1st_rational_riccati', '1st_power_series', 'lie_group']

In software

  • The logistic equation is a Bernoulli equation with n=2n = 2; the substitution v=1/Pv = 1/P is how its S-curve formula is usually derived.
  • Choosing variables that simplify a model is everyday work in simulation code: scaling to dimensionless variables (Dimensionless Variables) is a substitution, and it often reduces the number of parameters a solver must handle.

Exercises

Exercise 1: Bernoulli by hand

Solve y′−y=−y2y' - y = -y^2 (the logistic equation with r=K=1r = K = 1) using v=1/yv = 1/y.

Answer

y=11+Ce−xy = \frac{1}{1 + Ce^{-x}}.

Solution

n=2n = 2, v=y−1v = y^{-1}, so v′=−y−2y′=−y−2(y−y2)=−v+1v' = -y^{-2}y' = -y^{-2}(y - y^2) = -v + 1. Then v′+v=1v' + v = 1 gives v=1+Ce−xv = 1 + Ce^{-x} and y=1/vy = 1/v.

Exercise 2: Homogeneous

Solve y′=yx+1y' = \frac{y}{x} + 1 for x>0x > 0.

Answer

y=xln⁡x+Cxy = x\ln x + Cx.

Solution

v=y/xv = y/x: v+xv′=v+1v + xv' = v + 1, so v′=1xv' = \frac{1}{x} and v=ln⁡x+Cv = \ln x + C. (The equation is also linear, and the integrating factor 1/x1/x gives the same answer.)

Exercise 3: Linear combination (code)

Solve y′=(x+y)2y' = (x + y)^2, y(0)=0y(0) = 0 and evaluate y(1)y(1). Compare with solve_ivp.

Answer

y=tan⁡x−xy = \tan x - x, so y(1)=tan⁡1−1≈0.557408y(1) = \tan 1 - 1 \approx 0.557408.

Solution

From the lesson, y=tan⁡(x+C)−xy = \tan(x + C) - x; y(0)=tan⁡C=0y(0) = \tan C = 0 gives C=0C = 0.

python · try it yourself
import numpy as np
from scipy.integrate import solve_ivp
sol = solve_ivp(lambda x, y: (x + y)**2, (0, 1), [0.0], rtol=1e-10, atol=1e-12)
print(f"{sol.y[0][-1]:.6f} {np.tan(1) - 1:.6f}")
0.557408 0.557408

The solution blows up at x=π/2x = \pi/2, where tan⁡\tan does.

Test yourself

Which substitution turns y′+p(x)y=q(x)y4y' + p(x)y = q(x)y^4 into a linear equation?

  1. v=y4v = y^4
  2. v=y−3v = y^{-3}
  3. v=y/xv = y/x
  4. v=x+yv = x + y

For y′=F(y/x)y' = F(y/x), the substitution v=y/xv = y/x gives $y' = $…

  1. v′v'
  2. v+xv′v + xv'
  3. xv′xv'
  4. v/xv/x

After substituting v=x+yv = x + y in y′=f(x+y)y' = f(x + y), the equation for vv is…

  1. v′=f(v)v' = f(v)
  2. v′=1+f(v)v' = 1 + f(v)
  3. v′=xf(v)v' = x f(v)
  4. linear