Integrating Factor for Differential Equations Example 4

Home»Math Guides»Integrating Factor Solved Example 4

How to find the Integrating Factor for solving Ordinary Differential Equations (ODEs), Simplifying a rational function with long division and arctan

Let’s solve another practice example, this time the integrating factor is a tricky rational function we need to simplify.

Example problem: Solve the following ODE using an integrating factor: \((1 + {x^2})y’ = 2xy + {x^2} + {x^4}\), given the initial condition \(y(0) = 1\)

First we need to get it into a form where we can use the integrating factor. Make sure the coefficient of y’ is +1, and make sure the y’ and y terms are on the left-hand side.

We need to divide throughout by \((1 + {x^2})\)

\[y’ – \frac{{2xy}}{{(1 + {x^2})}} = \frac{{{x^2} + {x^4}}}{{(1 + {x^2})}}\]

The integrating factor will be e to the power of the integral of everything attached to the “y” term.

\[\mu = {e^{\int { – \frac{{2x}}{{(1 + {x^2})}}} dx}}\]

For now let us just consider the integral contained within.

\[\int { – \frac{{2x}}{{(1 + {x^2})}}dx} \]

We can use regular substitution.

Let \(u = {x^2} + 1\), then \(du = 2xdx\)

\[\int { – \frac{{du}}{u}} \]

\[ – \ln \left| u \right|\]

Reverse substitute to get x terms again.

\[ – \ln \left| {{x^2} + 1} \right|\]

If you state that x > 0, then you can remove the absolute signs.

\[ – \ln \left( {{x^2} + 1} \right)\]

When using logarithms, you can move the coefficient, here it is -1, and raise it to the power of the argument.

These are common “logarithm laws” that are well-known and are used to simplify difficult expressions.

\[\ln {\left( {{x^2} + 1} \right)^{ – 1}}\]

But to the power of negative one is just the reciprocal.

\[\ln \left( {\frac{1}{{{x^2} + 1}}} \right)\]

\[\mu = {e^{\ln \left( {\frac{1}{{{x^2} + 1}}} \right)}}\]

You can cancel out the e and ln.

\[\mu = \frac{1}{{{x^2} + 1}}\]

Now, we multiply the simplified integrating factor on both sides of the ODE and integrate both sides.

Remember that the left side of the solution will always be y times the integrating factor.

\[\frac{y}{{{x^2} + 1}} = \int {\frac{{x(x + {x^3})}}{{{{\left( {{x^2} + 1} \right)}^2}}}} dx\]

Now we consider the right-hand side.

\[\frac{{x(x + {x^3})}}{{{{\left( {{x^2} + 1} \right)}^2}}}\]

Factor and simplify.

\[\frac{{{x^2}(1 + {x^2})}}{{{{\left( {{x^2} + 1} \right)}^2}}}\]

\[\frac{{{x^2}}}{{1 + {x^2}}}\]

This fraction can be simplified even further using long division.

We don’t have a section on how to do long division of polynomials, but click here to see a YouTube video from The Organic Chemistry Teacher.

After long division, you get the following:

\[1 – \frac{1}{{{x^2} + 1}}\]

So this is the right-hand side, which is what we need to integrate:

\[\int {1 – \frac{1}{{{x^2} + 1}}} dx\]

The second term itself is tricky.

You need to know that that integral is actually just arctan(x).

Usually it’s given on a cheat sheet or a list of integrals.

You can solve the integral fully yourself using trigonometric substitution, click here to see a video from Integrals ForYou explaining how to fully do the integral yourself.

Anyways, when you integrate both sides, you obtain:

\[\frac{y}{{{x^2} + 1}} = x – \arctan (x) + C\]

We can now use the initial condition, \(y(0) = 1\), to solve for C. It just means sub in x = 0 and y = 1.

The values of the arctan function are something you should memorize like the sine and cosine points, here arctan(0)=0. Try Rapidtables to see some example arctan points.

\[\frac{1}{1} = 0 – 0 + C\]

So, C=1

Our final solution can then be cleaned up to be more elegant:

\[y = \left( {{x^2} + 1} \right)\left( {x – \arctan (x) + 1} \right)\]

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 = (1+x^2)*diff(y,x) == 2*x*y + x^2 + x^4;
S = dsolve(eqn)

Next, try an application question with Newton’s Law of Cooling involving the temperature of a dead body! 

Click here to return to the Math Guides hubpage

Leave a Comment