TSE.
MathematicsFinanceHealthPhysicsEngineeringBrowse all

Mathematics · Calculus · Differential Calculus

Differential Equation Solver

Solves first-order linear ordinary differential equations of the form dy/dx + P(x)y = Q(x) using the integrating factor method.

Calculator

Advertisement

Formula

The standard form of a first-order linear ODE is dy/dx + P(x)y = Q(x). The integrating factor μ(x) = e^(∫P(x)dx) is multiplied through the equation to make the left side an exact derivative. For the constant-coefficient case with P(x) = p (a constant) and Q(x) = q (a constant): μ(x) = e^(px), and the general solution simplifies to y(x) = (q/p) + C·e^(−px). The constant C is determined by the initial condition y(x₀) = y₀. Here: p is the coefficient of y, q is the forcing constant, x₀ is the initial x-value, y₀ is the initial y-value, and C is the integration constant.

Source: Boyce, W. E. & DiPrima, R. C. — Elementary Differential Equations and Boundary Value Problems, 11th Edition, Wiley (2017).

How it works

A first-order linear ODE with constant coefficients takes the form dy/dx + py = q, where p is a real constant multiplying the unknown function y(x), and q is a constant forcing term (or source). The goal is to find a function y(x) that satisfies the equation for all x, along with a specified initial condition y(x₀) = y₀. These problems arise naturally whenever the rate of change of a quantity is proportional to its current value plus an external input — a remarkably common pattern in the physical and social sciences.

The integrating factor method is the standard approach for solving these equations analytically. The integrating factor is μ(x) = e^(px). Multiplying both sides of the ODE by μ(x) converts the left side into the exact derivative d/dx[μ(x)·y(x)], making the equation directly integrable. For constant coefficients, this yields the general solution y(x) = q/p + C·e^(−px), where the equilibrium value q/p is the particular solution and C·e^(−px) is the complementary (homogeneous) solution. When p = 0, the equation reduces to dy/dx = q with the simple linear solution y(x) = y₀ + q(x − x₀). The integration constant C is determined uniquely by substituting the initial condition y(x₀) = y₀, giving C = (y₀ − q/p)·e^(px₀).

Practical applications of this solver span many disciplines. In electrical engineering, an RL circuit satisfies dI/dt + (R/L)I = V/L — exactly this form — and the solution describes how current builds up toward a steady state. In thermodynamics, Newton's law of cooling gives dT/dt + kT = kT_env. In pharmacokinetics, drug concentration in the bloodstream follows dC/dt + kC = dose_rate. In finance, continuously compounded savings accounts with constant deposits obey the same structure. Understanding the equilibrium value q/p is especially useful: it represents the long-run behaviour of the system as x → ∞ (when p > 0), and the term C·e^(−px) describes the transient decay toward that equilibrium.

Worked example

Problem: Solve dy/dx + 2y = 6, with the initial condition y(0) = 1. Find the solution at x = 1.

Step 1 — Identify coefficients: Here p = 2 and q = 6.

Step 2 — Integrating factor: μ(x) = e^(∫2 dx) = e^(2x).

Step 3 — Particular solution: The equilibrium (particular) solution is q/p = 6/2 = 3.

Step 4 — General solution: y(x) = 3 + C·e^(−2x).

Step 5 — Apply initial condition: y(0) = 1 → 1 = 3 + C·e^0 → C = 1 − 3 = −2. So C = (y₀ − q/p)·e^(p·x₀) = (1 − 3)·e^0 = −2.

Step 6 — Particular solution: y(x) = 3 − 2e^(−2x).

Step 7 — Evaluate at x = 1: y(1) = 3 − 2e^(−2) = 3 − 2·(0.135335) ≈ 3 − 0.270671 ≈ 2.729329.

Interpretation: Starting below the equilibrium of 3, the solution rises exponentially toward y = 3 as x increases. By x = 1, the solution has already reached approximately 91% of the equilibrium value, reflecting the fast decay rate e^(−2x) determined by p = 2.

Limitations & notes

This solver handles only first-order linear ODEs with constant coefficients p and q. It does not support variable-coefficient equations such as dy/dx + P(x)y = Q(x) with non-constant P or Q, nor does it handle nonlinear ODEs (e.g., Bernoulli or Riccati equations), systems of ODEs, or higher-order equations. When p = 0, the formula reduces to a simple linear ramp and the equilibrium output is undefined — this case is handled separately in the calculation. Very large values of |p·x| may cause numerical overflow or underflow in the exponential terms; for such cases, consider rescaling variables. The solver assumes x is a real variable and does not perform complex arithmetic. Initial conditions with very large magnitudes combined with large |p| values can produce results that are numerically indistinguishable from the equilibrium value due to floating-point precision limits. For stiff equations or non-constant coefficients, numerical methods such as Euler's method, Runge-Kutta (RK4), or dedicated ODE software (MATLAB ode45, Python scipy.integrate.solve_ivp) should be used instead.

Frequently asked questions

What is an integrating factor and why is it used?

An integrating factor μ(x) = e^(∫P(x)dx) is a function multiplied through the ODE to transform the left side into an exact derivative d/dx[μ·y], making the equation directly integrable. It is the standard method for solving all first-order linear ODEs analytically and always exists when P(x) is continuous.

What does the equilibrium value q/p represent physically?

The equilibrium (or steady-state) value q/p is the long-term value that y(x) approaches as x → ∞, provided p > 0. It represents the balance point where the forcing term q exactly counteracts the decay term py, so the net rate of change is zero. In an RL circuit, this would be the final steady-state current V/R.

Can this calculator solve second-order differential equations?

No — this tool is specifically designed for first-order linear ODEs with constant coefficients. Second-order equations such as y'' + by' + cy = f(x) require different techniques including the characteristic equation method, variation of parameters, or Laplace transforms, which are outside the scope of this calculator.

What happens when the coefficient p is negative?

When p < 0, the homogeneous solution C·e^(−px) = C·e^(|p|x) grows exponentially rather than decaying. This means the system is unstable: small perturbations from the equilibrium grow without bound over time. The equilibrium value q/p still exists as a mathematical particular solution, but it is an unstable equilibrium.

How do I solve dy/dx = ky (pure exponential growth) with this tool?

Rewrite dy/dx = ky as dy/dx + (−k)y = 0, so set p = −k and q = 0. The equilibrium q/p = 0, and the constant C = y₀·e^(−kx₀). The solution evaluates to y(x) = y₀·e^(k(x−x₀)), which is the classic exponential growth or decay formula used in radioactive decay, population dynamics, and compound interest.

Last updated: 2025-01-15 · Formula verified against primary sources.