Numerical Methods · interactive
A Bernoulli equation looks hopelessly nonlinear — until one substitution, v = y¹⁻ⁿ, turns it into a plain linear ODE you already know how to solve. Type your own P(x), Q(x), and power n, click to drop an initial condition, and watch the substituted solution land exactly on top of a direct numerical integration of the original equation.
y(x) · direct integration of the nonlinear ODE vs. back-substituted from v(x)
Click anywhere on the plane to start a solution from that point.
n = 0 or n = 1 makes the equation already linear — the substitution still works, it's just trivial.
Differentiate v = y1-n: by the chain rule, v′ = (1−n)y−ny′. Divide the original equation through by yn first — y−ny′ + P(x)y1−n = Q(x) — and every term is now expressible in v and v′. The messy power yn has vanished, leaving a first-order linear ODE in disguise. Solve it with an integrating factor (or, as here, numerically), then undo the substitution: y = v1/(1−n).
Rather than trust the algebra blindly, this lab runs two independent computations from the same initial condition: RK4 directly on the original nonlinear equation, and RK4 on the transformed linear v-equation, then converted back via y = v1/(1−n). They land on top of each other (see the "max difference" stat) — the substitution isn't just a trick, it's an exact change of variables, and the two paths are solving the same problem two different ways.
The logistic growth equation y′ = ry(1 − y/K) is a Bernoulli equation with n = 2 — population, market saturation, or epidemic models all reduce to this. Falling bodies with velocity-squared drag, and certain chemical reaction-rate equations, are also Bernoulli in disguise. Once you spot the pattern y′ + P(x)y = Q(x)yn, the substitution is always the same move.
Try the "blows up!" preset: with strong enough positive feedback, the solution races to infinity in finite x — a genuine mathematical blow-up, not a numerical glitch. Near that singularity the two curves can visibly diverge from each other, because both integrators are stepping through a region where the slope itself is becoming infinite; tiny step-size differences get amplified enormously. That's a feature, not a bug, of finite-time blow-up — it's the same sensitivity you'd see trying to numerically integrate any equation right up to a vertical asymptote.
EngineeringCandy · Numerical Methods · the v = y¹⁻ⁿ substitution verified live by two independent integrations · build it, break it, learn