Differential Equation Solver Step by Step
- Half-life
- h
- Result
- Time (hours)
- 2 h
- You entered
- Initial amount
- 100 mg
- You entered
This page explains how to solve ordinary differential equations (ODEs) step by step, covering the main analytical methods, how to choose between them, and common pitfalls. You enter a differential equation and an initial condition, and the step-by-step process shows the algebraic manipulations that lead to the solution.
Formula
The calculator above solves the first-order linear ODE dy/dt = -k·y with initial condition y(0) = y₀. The solution is:
y(t) = y₀ · e−k·t
- y(t) – amount remaining at time t (mg)
- y₀ – initial amount at t = 0 (mg)
- k – positive decay rate (1/hour)
- t – elapsed time (hours)
This is the classic exponential decay model, used for radioactive decay, drug elimination, and capacitor discharge.
Worked Example
Using the defaults: y₀ = 100 mg, k = 0.3 per hour, t = 2 hours.
- Write the equation: dy/dt = −0.3·y, y(0) = 100.
- Separate variables: dy/y = −0.3 dt.
- Integrate both sides: ln|y| = −0.3t + C.
- Solve for y: y = eC·e−0.3t = A·e−0.3t.
- Apply y(0) = 100: A = 100.
- Evaluate at t = 2: y(2) = 100·e−0.6 ≈ 100·0.5488 = 54.88 mg.
The calculator gives 54.88 mg, matching this hand calculation. The half-life is ln(2)/0.3 ≈ 2.31 hours.
What a Step-by-Step Solver Actually Does
When you ask for a step-by-step solution, the solver must first identify the type of ODE. The most common types taught in introductory courses are:
- Separable – can be written as dy/dx = f(x)·g(y).
- First-order linear – dy/dx + P(x)y = Q(x), solvable with an integrating factor.
- Exact – M(x,y)dx + N(x,y)dy = 0 where ∂M/∂y = ∂N/∂x.
- Bernoulli – dy/dx + P(x)y = Q(x)yⁿ, reducible to linear.
- Second-order with constant coefficients – ay″ + by′ + cy = 0, solved via characteristic equation.
For each type, the solver applies a fixed algorithm, showing each algebraic step. For example, for a linear first-order equation, it computes the integrating factor μ(x) = e∫P(x)dx, multiplies both sides, recognizes the left side as a derivative of μ·y, integrates, and solves for y.
How to Solve an ODE by Hand – The General Process
Even if you use an online solver, understanding the manual process helps you verify results. The typical workflow is:
- Identify the order – the highest derivative present.
- Classify linearity – is y or its derivatives multiplied together or raised to powers other than 1?
- Check for separability – can you move all y terms to one side and all x terms to the other?
- Apply the appropriate method – separation, integrating factor, characteristic equation, etc.
- Find the general solution – include the arbitrary constant C.
- Apply initial/boundary conditions – if given, solve for C.
- Verify – plug the solution back into the original equation.
For example, solve y′ = 2x·y. Separate: dy/y = 2x dx. Integrate: ln|y| = x² + C, so y = A·ex². If y(0)=3, then A=3, so y = 3ex².
Choosing the Right Method
Selecting the method is the hardest part for beginners. Here is a practical decision guide:
- If the equation is first-order and you can separate variables, do that first.
- If it is first-order but not separable, check if it is linear (form y′ + P(x)y = Q(x)). If yes, use an integrating factor.
- If it is first-order and nonlinear but has the form y′ + P(x)y = Q(x)yⁿ, try a Bernoulli substitution u = y1−n.
- If it is second-order with constant coefficients, write the characteristic equation ar² + br + c = 0 and solve for r.
- If it is exact, find a potential function F such that ∂F/∂x = M and ∂F/∂y = N.
When an equation fits none of these, numerical methods (Euler, Runge-Kutta) are the fallback.
Common Mistakes and How to Avoid Them
Step-by-step solving often goes wrong due to small algebraic errors. The most frequent issues are:
- Forgetting the constant of integration – every indefinite integral produces a C; you need it to apply initial conditions.
- Incorrect separation – you must move all y terms (including dy) to one side and all x terms (including dx) to the other, with no mixing.
- Misapplying the integrating factor – the equation must be in the exact form y′ + P(x)y = Q(x) before multiplying by μ.
- Sign errors in the characteristic equation – for ay″ + by′ + cy = 0, the equation is ar² + br + c = 0, not ar² − br + c.
- Dropping absolute values in logarithms – ln|y|, not ln y, unless you know y is positive.
- Rounding too early – keep exact forms (e, π, fractions) until the final step.
Always verify your final answer by substituting it back into the original ODE.
Limits of Analytical Step-by-Step Solvers
Many real-world differential equations have no closed-form solution. For example, the simple-looking equation y′ = x² + y² cannot be solved with elementary functions. In such cases, a step-by-step solver will either fail or return a complicated implicit expression. Numerical solvers, on the other hand, give approximate values at discrete points. The step-by-step approach is most valuable for textbook problems and for building intuition, but it is not a universal tool.
Also note that some equations have multiple solutions or no solution at all. The existence and uniqueness theorem (Picard–Lindelöf) gives conditions under which a unique solution exists, but checking those conditions is beyond what most step-by-step solvers show.
Frequently Asked Questions
What is the difference between an ordinary and a partial differential equation?
An ordinary differential equation (ODE) has one independent variable, like y′(x) = x. A partial differential equation (PDE) has two or more independent variables and uses partial derivatives, like ∂u/∂t = ∂²u/∂x². This page deals only with ODEs.
How do I know if an equation is linear?
An ODE is linear if the dependent variable y and all its derivatives appear only to the first power and are not multiplied together. For example, y′ + 2xy = sin(x) is linear; y′ + y² = 0 is nonlinear.
Can a step-by-step solver handle initial value problems?
Yes, most solvers accept an initial condition like y(0)=1 and will use it to find the particular solution. If no initial condition is given, they return the general solution with an arbitrary constant.
What is the integrating factor and when do I use it?
The integrating factor is μ(x) = e∫P(x)dx used to solve first-order linear ODEs of the form y′ + P(x)y = Q(x). Multiplying both sides by μ turns the left side into (μ·y)′, which can be integrated directly.
Why does my solution have a logarithm in it?
Logarithms appear when integrating 1/y, which happens after separation of variables. They often disappear when you exponentiate both sides. For example, ln|y| = x + C becomes y = ±eCex.
What if my equation is not separable, linear, or exact?
Try a substitution (Bernoulli, homogeneous), or use a numerical method. For many practical problems, numerical approximation is the only feasible route.
Related
Formula used
in t | Time (hours) | h | 2 | 0 in y0 | Initial amount | mg | 100 | 0 in k | Decay rate (per hour) | 1/h | 0.3 | 0 out y | Amount after t hours | mg | y0 * exp(-k * t) | 2 out half | Half-life | h | ln(2) / k | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.