Key takeaways
- Standard form: y' + p·y = q.
- Integrating factor: μ = e^(∫p dx), which is e^(px) for constant p.
- Solution with constants: y = q/p + (y₀ − q/p)·e^(−px).
- q/p is the equilibrium: the steady level y settles to when p > 0.
In this guide
What is a first-order linear ODE?
It is an equation involving y and its first derivative y', where y and y' appear only to the first power (no y², no √y). The standard shape is y' + P(x)·y = Q(x).
A friendly picture: a bucket with a hole. Water pours in at a steady rate q, and leaks out at a rate p·y that grows with how much water y is inside. So y' = q − p·y, or y' + p·y = q. At first the level rises fast. Then the leak catches up, and the level settles where inflow equals outflow.
This calculator solves the case where p and q are constants, with a starting value y(0) = y₀.
Why does this equation matter?
The 'fill and leak' pattern is one of the most common in science. A capacitor charging, a medicine drip, a room warming up, a falling object reaching top speed: each one rises quickly, then levels off at a steady value.
The integrating factor is also a clever idea you'll use again and again. It turns a messy left side into the derivative of a single product, which you can simply integrate.
After a time of 1/p, the gap between y and the steady level has shrunk to about 37% of what it was. That's why engineers talk about 'time constants'.
The formula
| Symbol | What it means | Example |
|---|---|---|
| p | Constant coefficient of y: how strongly y pulls back | 0.5 per hour |
| q | Constant input term: the steady supply | 10 mg per hour |
| y₀ | Starting value y(0) | 0 mg |
| x | Where you want the answer, often a time | 2 hours |
| q/p | The equilibrium level | 20 mg |
The general method uses the integrating factor μ = e^(∫P dx), which is e^(px) here. If p = 0, the equation is just y' = q, and the calculator gives y₀ + qx.
How to solve it step by step
- 1Write it in standard form.
y' + p·y = q, with y' having coefficient 1. - 2Find the integrating factor.
μ = e^(px). - 3Multiply both sides by μ. The left side becomes
(e^(px)·y)', the product rule in reverse. - 4Integrate both sides.
e^(px)·y = (q/p)e^(px) + C, soy = q/p + C·e^(−px). - 5Use the starting value.
C = y₀ − q/p. Then put in x.
Now enter your own p, q, starting value and x below to see the integrating factor at work.
Try it yourself
Pre-filled with the example — change any value.
Common mistakes to avoid
- Getting the sign of the exponent wrong.
μ = e^(+∫P dx), and the solution decays likee^(−px). - Forgetting the constant C before using the initial condition.
- Moving p·y to the wrong side.
y' = q − pybecomesy' + py = q, so p keeps its sign. - Using this for y' = ky only. That one is also separable, which is quicker.
Tips and tricks
- Time constant: after
x = 1/p, y has covered about 63% of the way from y₀ to q/p. - Check: put x = 0 into your answer. You must get y₀.
- Negative p: the exponential grows instead, and y runs away from q/p.
Where you'll use it in real life
- Medicine: a drip adding a drug while the body clears it.
- Electronics: a capacitor charging in an RC circuit.
- Chemistry: a mixing tank with salt water flowing in and out.
- Physics: Newton's law of cooling and a falling object with air resistance.
Quick summary
For y' + p·y = q, multiply by the integrating factor e^(px), integrate, and use the starting value to get y = q/p + (y₀ − q/p)e^(−px). The solution slides from y₀ towards the steady level q/p. Use the calculator above to see the full working.
Worked example
A hospital drip adds a medicine at 10 mg per hour, and the body removes it at a rate of 0.5 times the amount present, so y' + 0.5y = 10. The patient starts with none. How much is in the body after 2 hours? Use p = 0.5, q = 10, y₀ = 0 and x = 2.
- 01ODE: y' + 0.5y = 10, y(0) = 0
- 02Integrating factor: μ = e^(∫0.5dx) = e^(0.5x)
- 03Multiply through: (e^(0.5x)y)' = 10e^(0.5x)
- 04Integrate: e^(0.5x)y = 20e^(0.5x) + C
- 05y = 20 + C·e^(−0.5x)
- 06Apply y(0)=0: 0 = 20 + C → C = -20
- 07y(x) = 20 + -20·e^(−0.5x)
- 08At x = 2: 12.6424
These numbers are pre-filled in the calculator above.
Frequently asked questions
What is an integrating factor?
It is the multiplier μ = e^(∫P dx). Multiplying y' + Py = Q by it turns the left side into the derivative of μ·y, which you can integrate directly.
What is the equilibrium solution of y' + py = q?
Set y' = 0 to get y = q/p. When p > 0, every solution moves towards this value over time. In the drip example it is 10 ÷ 0.5 = 20 mg.
What is the solution of y' + y = 2 with y(0) = 0?
y = 2 − 2e⁻ˣ. At x = 1 it equals 2 − 2/e ≈ 1.2642.
What if p = 0?
Then there is no leak, the equation is y' = q, and y simply grows in a straight line: y = y₀ + q·x.


