From the workbench / Mathematics

Solving a first-order initial-value problem

Use an initial value to select a solution of y′ = ay + b, check it by substitution, and compare the closed form with Euler and Runge–Kutta estimates.

Open first-order linear ode calculator

Start with the equation and one known value

An initial-value problem supplies a differential equation and the value of its solution at a particular starting point. The first-order linear calculator supports y′ = ay + b with constant real a and b. Enter the coefficients, initial x and y, and the x where you want the result.

For example, y′ = −2y + 6 with y(0) = 1 describes a solution moving toward the equilibrium value 3 as x increases. Enter a = −2, b = 6, initial x = 0, initial y = 1, and evaluate at x = 1.

y′=−2·y+6
y(0)=1

Use the initial value to choose the constant

The constant solution is y = 3. Subtract it by writing u = y − 3; the remaining equation is u′ = −2u. Its solutions are exponential. Since u(0) = −2, the required solution is 3 − 2e⁻²ˣ.

The integrating-factor method reaches the same result: rewrite the equation as y′ + 2y = 6 and use the factor e²ˣ. The initial value then fixes the one integration constant. For general constant coefficients with a ≠ 0, use the shifted origin x − x₀ in the formula below.

y(x)=3−2·e−2·x
y(x)=−ba+(y0+ba)·ea·(x−x0)

Check the equation as well as the starting value

At x = 0, the solution gives 3 − 2 = 1, as required. Its derivative is 4e⁻²ˣ. Substituting the solution into −2y + 6 also gives 4e⁻²ˣ, so it satisfies the differential equation for every real x.

At x = 1, the value is approximately 2.7293294335. The solution remains below 3 for finite x and approaches 3 as x increases, consistent with the equation’s direction of change. A check at one evaluation point is useful; differentiating the formula establishes the identity across its domain.

y′(x)=4·e−2·x
−2·y(x)+6=4·e−2·x
y(1)=3−2·e−2≈2.7293294335

Compare with a numerical solution

In the Euler & Runge–Kutta tool, enter the derivative as -2*y+6, start at x = 0 and y = 1, and take ten steps of size 0.1 to reach x = 1. Euler follows the slope at the start of each step; classical RK4 combines four slope evaluations.

Repeat with twenty steps of size 0.05 to reach the same endpoint. Both methods move closer to the closed-form value in this example. RK4 is much closer on these grids, but the comparison is specific to this smooth equation and these step sizes.

Estimates at x = 1; displayed to nine decimal places
Methodh = 0.1; 10 stepsh = 0.05; 20 steps
Euler2.7852516352.756846691
Classical RK42.7293209032.729328943
Closed form2.7293294342.729329434

Choose the solver that matches the problem

When a = 0, the equation becomes y′ = b and its solution is the line y = y₀ + b(x − x₀). The first-order linear tool handles that case separately. For small nonzero a, it evaluates the exponential difference carefully; extreme exponentials and cancellation can still limit a numerical result.

This closed-form calculator does not solve variable-coefficient or nonlinear equations. The separate Euler & Runge–Kutta tool accepts a restricted f(x, y) expression and 1–80 fixed steps. It is not an adaptive or stiff solver, does not certify an error tolerance, and does not establish that a solution remains valid through a singularity.

Even with a known formula, its evaluated value is a floating-point approximation. Check the equation, initial value, interval and units before interpreting it as a physical model. The tools reject nonfinite results and values beyond their stated numerical range.

y(x)=y0+b·(x−x0)

References & further reading

Equations describe the stated model. Worked values are rounded for reading; the calculator’s download retains its calculated precision. Read about our checks and their limits.

Try the example, then change one input at a time.

Open calculator More guides