Home»Math Guides»Integrating Factor Solved Example 1
How to use the Integrating Factor to solve Ordinary Differential Equations
You may need to use an “integrating factor” to solve a first-order ordinary differential equation.
You will definitely need to use an integrating factor to solve inseparable first-order differential equations.
You can use the integrating factor for separable first-order ODEs too if you want to, though it takes more work in that case.
The key is to write the differential equation in the proper form, and being careful when performing the integrating steps.
Get practice performing integration with examples here.
Example problem: Solve the differential equation, \({x^2}\frac{{dy}}{{dx}} + 3xy = 1\)
To use the integrating factor, you need a coefficient of “+1” in-front of the \(\frac{{dy}}{{dx}}\) term. So we divide throughout by \({x^2}\).
\[\frac{{dy}}{{dx}} + \frac{{3y}}{x} = \frac{1}{{{x^2}}}\]
Now use the integrating factor, you set it to e to the power of the integral of what is in front of the “y” term in the ODE above.
\[\mu (x) = {e^{\int {\frac{3}{x}dx} }}\]
And we solve it.
Be careful, the integral of 1/x is ln|x|, which is absolute x.
To remove the absolute sign, you need to state that the solution only exists for x > 0.
Once you remove the absolute sign, the e and natural logarithm, ln, will “cancel out”.
\[\mu (x) = {e^{\ln {{\left| x \right|}^3}}}\]
\(\mu (x) = {x^3}\), for x > 0
Now, we multiply the ODE \(\frac{{dy}}{{dx}} + \frac{{3y}}{x} = \frac{1}{{{x^2}}}\) by the integrating factor, \({x^3}\)
\[{x^3}\frac{{dy}}{{dx}} + 3{x^2}y = x\]
Now just integrate both sides.
Memorize this, the left side integral will always be the integral of the derivative of the integrating factor times “y”.
It just means you will end up with the integrating factor times “y” on the left hand side, you don’t need to necessarily write it all out.
Just memorize that you will always end up with the integrating factor times “y” on the left-hand side, and then you just need to integrate the right-hand side normally, whenever you use an integrating factor.
When integrating the right-hand side, don’t forget to add a C, which represents a constant number.
\[\int {\frac{d}{{dx}}\left( {y{x^3}} \right)dx} = \int {xdx} \]
\[y{x^3} = \frac{1}{2}{x^2} + C\]
If you’re able to, it is a best practice to isolate the independent variable, y.
But only do this if it’s possible, if you have “y” terms all over the place, don’t try to isolate it.
Don’t forget in the final step to say the answer only exists for x > 0 because we had to remove the absolute symbols from the ln|x|.
Not mentioning that is an easy way for an instructor to deduct a nice mark from your otherwise perfect answer.
\(y = \frac{1}{{2x}} + \frac{C}{{{x^3}}}\) for x > 0
How to double-check the solution of your ODE integrating factor math problem using MATLAB
Do you want to double-check if the solution to the ODE math problem you were given is correct? But these problems are difficult, and don’t fit if you try a regular or graphing calculator. If only there was a “special calculator” that could find the solutions to ODEs….
But, there is! A program called MATLAB!
As long as your problem has an analytical solution you can use MATLAB’s symbolic solvers such as dsolve to find the analytical solution!
Note: it needs to be a question where you’re able to find an answer in the form of an equation, if you’re asked to find the “numerical solution” to an ODE you can’t do this!
You can use the following script m-file we made, if you have a different problem you can change the variable names and the equation itself, you don’t need to explicitly separate the derivative term either.
%bai-gaming.com/math-guides
syms y(x) x
eqn = x^2*diff(y,x) +3*x*y == 1;
S = dsolve(eqn)
And the output will be the same result we got! Great!
Try a harder integrating factor problem for solving an ODE, involving integration by parts as well!