Linear First-Order Differential Equation Calculator

Solve y' + P(x)y = Q(x) with the integrating factor method and graph the solution curve.

Linear First-Order ODE Calculator

Solves y′ + P(x)·y = Q(x) with an initial condition y(x₀) = y₀.

What Is a Linear First-Order Differential Equation?

A linear first-order differential equation has the standard form

y′ + P(x)·y = Q(x)

where the unknown function y and its derivative appear only to the first power and are never multiplied together. P(x) is the coefficient function and Q(x) the forcing term. Unlike most differential equations, this family has a complete recipe that always works: the integrating factor method. This calculator runs that recipe symbolically whenever the two required integrals have elementary forms, showing the factor, both integrations, and the constant fitted to your initial condition; when an integral has no closed form, it switches to a high-accuracy Runge-Kutta solution so you still get the curve and a check value.

How to Use the Linear First-Order ODE Calculator

Write your equation in standard form first, so the coefficient of y′ is 1, then enter P(x), Q(x), and the initial condition. An equation like xy′ + 2y = x³ must be divided through by x, giving P = 2/x and Q = x². Press solve: the steps construct μ(x) = e∫P dx, multiply the equation by it, integrate both sides, and isolate y. The graph traces the particular solution through (x₀, y₀) in both directions, and a check point one unit to the right lets you compare against homework answers instantly.

Worked Example

Solve y′ + 2y = ex with y(0) = 1, the default. The integrating factor is μ = e∫2 dx = e2x. Multiplying through:

(e2xy)′ = e2xex = e3x  ⇒  e2xy = e3x/3 + C

so y = ex/3 + Ce−2x. The condition y(0) = 1 gives 1 = 1/3 + C, hence C = 2/3 and y = ex/3 + (2/3)e−2x. Notice the anatomy: a particular response ex/3 driven by the forcing, plus a transient Ce−2x that dies away, the structure every linear first-order solution shares.

Why the Integrating Factor Works

The left side y′ + P y is almost, but not quite, the derivative of a product. Multiplying by μ(x) = e∫P dx fixes that on purpose: since μ′ = Pμ, the product rule gives (μy)′ = μy′ + μ′y = μ(y′ + Py). The whole left side collapses into one exact derivative, and the equation becomes (μy)′ = μQ, solvable by direct integration. The exponential is the unique choice with this collapsing property, which is why the method never fails on a linear equation: existence and uniqueness of the solution follow on any interval where P and Q are continuous. This structure also explains superposition: solutions of the forced equation differ from one another by solutions Ce−∫P dx of the homogeneous equation, the same particular-plus-homogeneous decomposition that governs second-order linear equations.

Steady States and Transients

When P is a positive constant, every solution converges to the same long-run behavior: the transient Ce−Px vanishes and only the forced response survives. Engineers call this the steady state, and the reciprocal 1/P the time constant, the horizon over which memory of the initial condition fades. Try the growth chip (P = −1) to see the opposite: a negative coefficient amplifies the homogeneous part, initial conditions matter forever, and tiny changes in y₀ produce diverging futures. Reading stability off the sign of P is the one-dimensional preview of eigenvalue analysis for systems.

Common Mistakes to Avoid

  • Skipping standard form. The formula μ = e∫P dx assumes the coefficient of y′ is 1. For 3y′ + 6y = x, divide by 3 first; using P = 6 instead of 2 corrupts everything downstream.
  • Forgetting the constant of integration inside μ. Any antiderivative of P works, and the conventional choice omits the constant. Adding one just rescales μ harmlessly, but adding it inconsistently between the two sides breaks the equality.
  • Dropping C before applying the initial condition. The constant appears when integrating μQ, and it must be divided by μ along with everything else: y = (∫μQ dx + C)/μ, not (∫μQ dx)/μ + C.
  • Treating a nonlinear equation as linear. y′ + y² = x is not linear (y is squared), and no integrating factor of this kind exists. Check that y and y′ appear alone and to the first power before reaching for this method.
  • Ignoring domain breaks. With P = 1/x the factor is |x|, and solutions live separately on x < 0 and x > 0. A solution through x₀ = 1 says nothing about negative x.

Real-World Applications

Linear first-order equations model any quantity that decays or grows at a rate proportional to itself while being pushed from outside. Newton's law of cooling is T′ + kT = kTenv; an RC circuit obeys V′ + V/(RC) = Vin/(RC); a drug infusion satisfies c′ + kc = r/V, giving the plateau concentration r/(kV) that pharmacologists target. Mixing problems, brine flowing through a tank, are the textbook staple: the salt amount obeys exactly this equation with P equal to the flow rate over the volume. In finance, an account with continuous interest and steady deposits follows the same mathematics with the sign of P flipped. Compare the numeric machinery with the Euler's method calculator and Runge-Kutta calculator, and see separable equations for the other big first-order solvable class.

Frequently Asked Questions

What makes a differential equation "linear"?

The unknown y and its derivatives appear to the first power, in separate terms, with coefficients depending only on x. So y′ + x²y = tan(x) is linear, while yy′ = x and y′ = sin(y) are not. Linearity is what guarantees the integrating factor recipe succeeds.

What exactly is an integrating factor?

A function μ(x) you multiply through the equation so the left side becomes the exact derivative (μy)′. For linear equations μ = e∫P dx always works, converting the ODE into a single integration. It is the continuous analogue of clearing denominators to make an expression collapse.

Why does the solution always split into transient plus steady parts?

Because the general solution is y = yₚ + Ce−∫P dx: one particular response to the forcing plus every multiple of the homogeneous solution. When ∫P dx grows without bound, the second piece decays, leaving the forced behavior that all initial conditions share.

What if ∫P dx or ∫μQ dx has no elementary antiderivative?

The method is still valid, the answer just stays in integral form, e.g. involving the error function for P = 2x with certain Q. This calculator detects that situation and switches to a fourth-order Runge-Kutta numeric solution, which draws the same curve the formula would describe.

How do I convert an equation into standard form?

Divide by whatever multiplies y′, then move the y-term to the left and everything else to the right. From x²y′ = 4 − xy: divide by x² and rearrange to y′ + (1/x)y = 4/x², so P = 1/x and Q = 4/x².

Does an initial condition always pick out exactly one solution?

Yes, on any open interval containing x₀ where P and Q are continuous; that is the existence-uniqueness theorem for linear equations. Geometrically the general solution is a one-parameter family of non-crossing curves, and the condition (x₀, y₀) selects the single member through that point.

What is the time constant of a linear first-order system?

For constant P > 0 it is τ = 1/P: after time τ the transient shrinks by the factor e, and after about 5τ it is effectively gone. Circuit designers quote RC and thermal engineers quote 1/k as time constants for precisely this equation.

How is this related to Bernoulli equations?

The Bernoulli equation y′ + P y = Q yⁿ is nonlinear, but the substitution v = y1−n transforms it into a linear equation for v, solved exactly as on this page. Many "unsolvable-looking" first-order equations are linear equations in disguise after a substitution.

Why does the graph extend the solution to the left of x₀ too?

A differential equation determines the curve in both directions from the initial point; integrating backward is just as valid as forward. Physically, backward solving reconstructs history, e.g. inferring an object's earlier temperature from its cooling law and present reading.

When should I use this instead of separation of variables?

Separation needs the equation in the form y′ = f(x)g(y); a linear equation with genuine forcing, like y′ + 2y = ex, does not separate because of the sum. Conversely, some separable equations are nonlinear and off-limits to integrating factors. The two methods cover different overlapping territories: y′ + P(x)y = 0 belongs to both.