What it solves
A first-order differential equation y′ = f(x, y) tells you the slope of the solution at every point. With a starting value y(x₀) = y₀, there's usually exactly one solution curve. This differential solver follows that curve step by step. It handles growth and decay (y′ = ky), logistic growth (y′ = y(1 − y)), cooling, mixing problems and anything else you can write as y′ = f(x, y).
How it's calculated: Runge–Kutta (RK4)
k₂ = f(xₙ + h/2, yₙ + (h/2)k₁)
k₃ = f(xₙ + h/2, yₙ + (h/2)k₂)
k₄ = f(xₙ + h, yₙ + h·k₃)
yₙ₊₁ = yₙ + (h/6)(k₁ + 2k₂ + 2k₃ + k₄)
RK4 samples the slope four times per step and averages them. It's a fourth-order method: halving h cuts the error about 16-fold. The calculator reruns with h/2 and shows how much the answer moved, so you can see how many digits to trust. For comparison it also shows Euler's method, yₙ₊₁ = yₙ + h·f(xₙ, yₙ), which is only first-order.
For y′ = y with y(0) = 1 and h = 0.1, RK4 gives y(1) ≈ 2.718279744, against the exact value e ≈ 2.718281828. Euler's method with the same step gives only 2.593742.
The integrating factor method
If the equation is linear in y, it can be written y′ + P(x)y = Q(x). Then:
- Find the integrating factor μ(x) = e^(∫P(x) dx).
- Multiply through. The left side becomes (μy)′, so (μy)′ = μQ.
- Integrate both sides: μy = ∫μQ dx + C, then divide by μ.
- Use the initial value to find C.
The calculator does these steps whenever P and Q are simple enough to integrate, and checks the formula against the RK4 numbers.
Worked example
Solve y′ = 4 − 2y with y(0) = 0. In standard form, y′ + 2y = 4, so P = 2 and Q = 4.
- μ = e^(∫2 dx) = e^(2x).
- (e^(2x)y)′ = 4e^(2x), so e^(2x)y = 2e^(2x) + C.
- y = 2 + Ce^(−2x). With y(0) = 0, C = −2.
- y = 2 − 2e^(−2x), and y(1) = 2 − 2e⁻² ≈ 1.72932943.
Limitations
- One first-order equation at a time. Second-order equations and systems need to be rewritten as systems, which this calculator doesn't take.
- If the solution blows up (y′ = y² from y(0) = 1 reaches infinity at x = 1) or leaves the domain of f, the calculator stops and says where.
- Stiff equations, with very fast decay like y′ = −1000y, need a small step to stay stable. If halving h changes the answer a lot, make h smaller.
- The slope field is drawn on the graph's window only.