A complete interactive guide — from theory to practice
By the end of this lesson, you will be able to:
A first-order linear ordinary differential equation is an equation that relates an unknown function \(y(x)\) to its first derivative \(y'(x)\). It has the general form:
Here, \(P(x)\) and \(Q(x)\) are known functions of \(x\), and we want to find \(y(x)\). The equation is called linear because \(y\) and \(y'\) appear only to the first power — there are no terms like \(y^2\), \(\sin(y)\), or \(y \cdot y'\).
Make sure the coefficient of \(y'\) is exactly \(1\) before applying the method. If you have something like \(3y' + 6y = 9x\), first divide everything by 3 to get \(y' + 2y = 3x\).
First-order linear ODEs model countless real-world phenomena: radioactive decay, RC electrical circuits, Newton's law of cooling, mixing problems, population dynamics with harvesting, and more. Mastering this equation type gives you a powerful tool that appears throughout engineering and science.
Leonhard Euler systematized the integrating factor method in the 1730s, transforming the solution of linear differential equations from an art into a science. His work laid the foundation for all of modern engineering mathematics.
The key idea is beautifully simple: we multiply both sides of the equation by a cleverly chosen function — the integrating factor — that transforms the left side into an exact derivative.
Given the standard form \(\displaystyle \frac{dy}{dx} + P(x)\,y = Q(x)\), define the integrating factor:
Then the general solution is:
Let's see why this magic works. Start with:
Multiply both sides by \(\mu(x) = e^{\int P(x)\,dx}\):
Now notice that \(\mu'(x) = P(x)\,\mu(x)\) by the chain rule. So the left side is:
This is exactly the product rule in reverse! The equation becomes:
Now just integrate both sides:
And divide by \(\mu(x)\) to isolate \(y\). That's it!
The integrating factor is designed so that \(\mu' = P \cdot \mu\). This is what makes the left side collapse into a single derivative via the product rule. This is the heart of the entire method.
Here is the streamlined procedure to solve any first-order linear ODE:
The derivation above (in the Theory section) shows that multiplying by \(\mu(x)\) makes the left side collapse into a product rule derivative: \(\dfrac{d}{dx}[\mu(x)\,y]\). But in practice, you can skip straight to the formula once you know \(\mu(x)\) and \(Q(x)\). The formula encodes all those steps — just plug in and integrate!
Click each example to reveal the full step-by-step solution.
Step 1: Standard form. Already in standard form: \(P(x) = 2\), \(Q(x) = 6\).
Step 2: Integrating factor.
Step 3: Apply formula. Use \(y = \dfrac{1}{\mu}\left[\int \mu \cdot Q\,dx + C\right]\):
Step 4: Initial condition. Apply \(y(0)=1\): \(1 = 3 + C\), so \(C = -2\).
As \(x \to \infty\), the exponential term dies out and \(y \to 3\). The value \(y=3\) is the equilibrium solution. No matter the initial condition, all solutions converge to 3. Try it in the Explorer below!
Step 1: Standard form. \(P(x) = -3\), \(Q(x) = e^{2x}\).
Step 2: Integrating factor.
Step 3: Apply formula.
When \(P(x)\) is negative, solutions grow exponentially rather than decay. The behavior is fundamentally different from Example 1 — explore this in the visualizer!
Step 1: Standard form. Divide by \(x\):
So \(P(x) = \dfrac{1}{x}\) and \(Q(x) = x\) (for \(x > 0\)).
Step 2: Integrating factor.
Step 3: Apply formula.
Step 4: Initial condition. Apply \(y(1) = 2\): \(2 = \frac{1}{3} + C\), so \(C = \frac{5}{3}\).
This example shows that \(P(x)\) doesn't have to be constant. The integrating factor method works just as well for variable-coefficient equations — the integrating factor simply becomes a more interesting function (here, just \(x\)).
Step 1: Standard form. \(P(x) = \tan(x)\), \(Q(x) = \cos(x)\).
Step 2: Integrating factor.
Step 3: Apply formula.
Step 4: Initial condition. Apply \(y(0) = 0\): \(0 = (0 + C)\cdot 1\), so \(C = 0\).
Sometimes the integrating factor and \(Q(x)\) simplify beautifully when multiplied together. Here \(\sec(x)\cdot\cos(x) = 1\), making the integration trivial. Always simplify before integrating!
Problem Setup: A 500-liter tank initially contains pure water. A brine solution with concentration 0.05 kg/L flows in at 10 L/min, and the well-mixed solution flows out at the same rate. Find the amount of salt \(A(t)\) in the tank at time \(t\).
Step 1: Set up the equation. Rate of change = (rate in) − (rate out):
Standard form: \(P(t) = \dfrac{1}{50}\), \(Q(t) = 0.5\):
Step 2: Integrating factor.
Step 3: Apply formula.
Step 4: Initial condition. Apply \(A(0) = 0\) (pure water):
Equilibrium concentration: As \(t \to \infty\), the tank reaches equilibrium at \(A = 25\) kg, which means the concentration equals the inflow concentration: \(25/500 = 0.05\) kg/L. Time constant: The characteristic time scale \(\tau = 50\) minutes tells us how quickly the tank's composition changes. After time \(\tau\), the tank reaches \((1-e^{-1}) \approx 63\%\) of equilibrium. This mixing problem is fundamental in chemical engineering, used to design reactors, wastewater treatment systems, and pharmaceutical manufacturing processes.
Step 1: Standard form. Divide by $x$:
Thus $P(x) = \dfrac{1}{x}$ and $Q(x) = 2e^x$.
Step 2: Integrating factor.
Step 3: Apply formula.
Integrate by parts with $u = 2x$, $dv = e^x\,dx$:
Key insight: After the integrating factor is applied, the integral $\int \mu(x) \cdot Q(x)\,dx$ must be evaluated. For products like $xe^x$ or $x\sin(x)$, integration by parts is typically required. The formula $\int u\,dv = uv - \int v\,du$ is your most powerful tool when faced with such products. Practice this technique — it appears frequently in applied linear DEs!
Step 1: Standard form. $P(x) = \dfrac{2}{x}$ and $Q(x) = x^2$ (already in standard form).
Step 2: Integrating factor.
Step 3: Apply formula.
General rule: If $P(x) = \dfrac{n}{x}$ (a constant divided by $x$), then:
This gives an integrating factor that is a power of $x$, which is excellent for simplifying products and powers. This pattern appears constantly in applications ranging from heat diffusion to population dynamics. Watch for it!
Step 1: Standard form. $P(x) = \sin(x)$ and $Q(x) = \cos(x)$ (already in standard form).
Step 2: Integrating factor. We have $\int \sin(x)\,dx = -\cos(x) + C_0$, so:
Step 3: Apply formula.
Step 4: General (Implicit) Solution.
Critical insight: The integral $\displaystyle\int e^{-\cos(x)}\cos(x)\,dx$ has no elementary antiderivative. Even though the integrating factor method always works theoretically, it does not always yield a closed-form answer.
In practice: When faced with such integrals, we use numerical methods such as Euler's method, Runge-Kutta algorithms, or specialized ODE solvers (like those in SciPy or MATLAB). These approximate the solution to arbitrary precision without needing a formula.
Lesson: The integrating factor method is a powerful analytical tool, but nature does not always reward us with pretty answers. A working mathematician must be comfortable switching between analytical, numerical, and graphical approaches — and this example is a perfect reminder of that reality!
These problems are similar in style and difficulty to past exam questions. Click each problem to reveal the step-by-step solution.
Step 1: Write in standard form. Divide by $(1+x^2)$:
So $P(x) = \dfrac{2x}{1+x^2}$ and $Q(x) = \dfrac{3}{(1+x^2)^2}$.
Step 2: Find the integrating factor.
Let $u = 1 + x^2$, so $du = 2x\,dx$:
Step 3: Multiply through by $\mu(x) = 1+x^2$.
Step 4: Integrate both sides.
Step 5: Solve for $y$.
Notice that $P(x) = \dfrac{2x}{1+x^2}$ is the derivative of $\ln(1+x^2)$. This is a common pattern: whenever you see a derivative-like structure in $P(x)$, the integrating factor simplifies dramatically. Watch for rational functions of the form $\dfrac{f'(x)}{f(x)}$!
Step 1: Write in standard form. Divide by $x$:
So $P(x) = -\dfrac{3}{x}$ and $Q(x) = x^3\cos(x)$ (for $x > 0$).
Step 2: Find the integrating factor.
Step 3: Multiply through by $\mu(x) = \dfrac{1}{x^3}$.
Step 4: Integrate both sides.
Step 5: Apply initial condition $y(\pi) = 0$.
Thus $C = 0$.
Particular solution:
Check: If $y = x^3\sin(x)$, then $y' = 3x^2\sin(x) + x^3\cos(x)$, so:
$xy' - 3y = x(3x^2\sin(x) + x^3\cos(x)) - 3x^3\sin(x) = 3x^3\sin(x) + x^4\cos(x) - 3x^3\sin(x) = x^4\cos(x)$ ✓
A slope field (or direction field) draws small line segments showing the slope \(y' = Q(x) - P(x)\,y\) at many points. Solution curves must be tangent to these segments everywhere. Type your own equation or use a preset!
Click on the plot to trace a solution curve through that point!
Explore how the solution to \(y' + ay = b\) with \(y(0) = y_0\) changes as you adjust the parameters. The exact solution is:
See how Euler's method (a simple numerical approximation) compares to the exact solution. Adjust the step size to see how accuracy improves with smaller steps.
As you decrease the step size \(h\), Euler's method gets closer to the true solution. The error at each step is approximately \(O(h^2)\), so halving \(h\) roughly halves the local error — but doubles the number of steps needed. This trade-off between accuracy and computation is central to numerical methods.
Just as the integrating factor transforms a difficult equation into one that can be solved, perseverance transforms difficulty into mastery. If a problem seems hard, keep working — the clarity will come.
Test your understanding! Try each problem, then check your answer.
Progress: 0 / 6 completed
Which of the following is in standard form \(y' + P(x)y = Q(x)\)?
What is the integrating factor for \(y' + 5y = 10\)?
Find the general solution of \(y' + y = e^{-x}\).
Solve \(y' - y = 2\), \(y(0) = 5\). What is \(y(x)\)?
For the equation \(y' + \frac{2}{x}y = x^3\), what is \(\mu(x)\)?
For \(y' + 4y = 20\) with any initial condition, what is \(\displaystyle\lim_{x\to\infty} y(x)\)?
Standard form: \(\quad y' + P(x)\,y = Q(x)\)
Integrating factor: \(\quad \mu(x) = e^{\int P(x)\,dx}\)
General solution: \(\quad \displaystyle y = \frac{1}{\mu}\left[\int \mu \cdot Q\,dx + C\right]\)
For constant coefficients \(y' + ay = b\):
Equilibrium: \(\quad y_{eq} = b/a\) (when \(a > 0\), all solutions converge here)