Differential Equation Calculator

Solve the first-order differential equation dy/dx = ky (exponential growth or decay) with Euler's numerical method, and compare it against the exact analytical solution.

Results

Calculated
Euler approximation
—
Numerical y at target x
Exact solution
—
y = y0 · e^(k(x−x0))
Absolute error
—
|Euler − exact|
Step size h
—
(target x − x0) / n

How to use this calculator

This tool solves the first-order linear differential equation dy/dx = ky with initial condition y(x0) = y0 — the standard equation for exponential growth or decay. Enter the initial value, the rate constant k, the starting x0, the target x, and how many steps to use, then click Calculate. Click Clear to reset all fields to the defaults and start a new calculation.

The formula: Euler's method vs. the exact solution

Euler's method approximates the solution numerically by taking n equal steps of size h = (target x − x0) / n, updating the value at each step with ynew = y + h · k · y. Because this specific equation has a known closed form, the calculator also computes the exact answer directly: y(x) = y0 · ek(x−x0). Comparing the two shows exactly how much error Euler's straight-line steps introduce.

Interpreting the results

The highlighted Euler approximation is the numerical result of stepping through the equation n times. Exact solution is the true analytical value from the exponential formula. Absolute error is the gap between them — it shrinks as you increase the number of steps, since a smaller step size h tracks the true curve more closely. Step size h shows exactly how large each step was. If k is positive, y grows; if k is negative, y decays toward zero.

Frequently Asked Questions

What differential equation does this calculator solve?
It solves the first-order linear initial value problem dy/dx = ky, y(x0) = y0. This is the standard exponential growth or decay equation used for population growth, radioactive decay, continuous compound interest, and Newton's law of cooling, depending on the sign of the rate constant k.
What is Euler's method?
Euler's method is the simplest numerical technique for approximating the solution of dy/dx = f(x, y). Starting from y0 at x0, it takes n small steps of size h = (target x − x0) / n, updating y by y_new = y + h · f(x, y) at each step, tracing a piecewise-linear path toward the solution.
Why does the Euler approximation differ from the exact solution?
Euler's method follows straight-line segments while the true solution curves, so each step introduces a small truncation error that accumulates over the interval. The error is roughly proportional to the step size h, so increasing the number of steps (making h smaller) brings the approximation closer to the exact exponential solution.
Can this calculator handle any differential equation?
No. It is built specifically for dy/dx = ky, which has the closed-form exact solution y = y0 · e^(k(x−x0)). General nonlinear, non-separable, or higher-order differential equations need other numerical methods (such as Runge-Kutta) or a symbolic solver and are outside the scope of this tool.