Home»Math Guides»Integrating Factor Solved Example 2
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.
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.
Here we have an example where you need to use integration by parts to simplify after using the integrating factor.
Example problem: Solve the differential equation, \( – \frac{{dy}}{{dx}} = y + x\)
To use the integrating factor, you need a coefficient of “+1” in-front of the \(\frac{{dy}}{{dx}}\) term.
So we divide throughout by \( – 1\)
\[\frac{{dy}}{{dx}} = – y – x\]
We need to move the “y” term to the left-hand side of the equation to be able to use the integrating factor.
\[\frac{{dy}}{{dx}} + y = – x\]
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 1 dx}}\]
\[\mu (x) = {e^x}\]
Now, we multiply the ODE \(\frac{{dy}}{{dx}} + y = – x\) by the integrating factor, \({e^x}\)
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.
\[\int {\frac{d}{{dx}}y{e^x}} dx = \int { – x{e^x}dx} \]
Now just integrate both sides.
\[y{e^x} = – \int {x{e^x}dx} \]
For the right side, use integration by parts.
Remember that when using integration by parts you do want to follow certain priorities so that the computations will be easier, if you choose u and dv poorly, then you will have significantly more math to do to get to the answer.
The priority listed below was developed by Herbert Kasube in American Mathematical Monthly, and is called “LIATE” that you can memorize.
Choose u in the following priority, top being the highest priority and lowest being lower priority:
- Logarithm function
- Inverse trigonometric function
- Algebraic (polynomial) function
- Trigonometry function
- Exponential function
And then choose dv to be whatever remains.
Let \(u = x\), then \(du = dx\)
Let \(dv = {e^x}dx\), then \(v = {e^x}\)
Memorize the formula for integration by parts, it is: \(uv – \int {vdu} \), and substitute in the above values.
\[x{e^x} – \int {{e^x}dx} \]
\[ – \left( {x{e^x} – {e^x} + C} \right)\]
And substitute that into the right-hand side of our solution to the ODE.
\[y{e^x} = – x{e^x} + {e^x} + C\]
And isolate the “y” term if you can, here it’s easy, we divide throughout by \({e^x}\)
\[y = – x + 1 + \frac{C}{{{e^x}}}\]
The problem is not so bad, but what this means is that in your differential equations course, you need to know differentiation and integration techniques from your previous courses, which likely include techniques all throughout Calculus 1 to 3.
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 = -1*diff(y,x) == y + x;
S = dsolve(eqn)
See another integrating factor example, this time with a complicated trigonometric expression!