A harder example of solving a linear first order equation

Up a level : Differential Equations
Previous page : Homogenous differential equations - a more general type
Next page : Brine mixture, case 1, inflow=outflow, pure water in

(This page basically follows my train of thought, so it is not all too well structured, but that is on purpose – I want you to get a feeling of the thoughts involved.)

Solving differential equations can be quite hard, and even a small change to an equation can make it all but impossible to solve.  We previously found that

y' - xy = x

has the solution

y = C{e^{\frac{{{x^2}}}{2}}} - 1

Let us now instead look at

y' - xy = {x^2}

This is a linear first-order equation that is not separable, so we may try using an integration factor. We get

I = {e^{\int {( - x)dx} }} = {e^{ - {x^2}/2}}

This gives us

{e^{ - {x^2}/2}}y' - {e^{ - {x^2}/2}}xy = {e^{ - {x^2}/2}}{x^2}

or

({e^{{x^2}/2}}y)' = {e^{{x^2}/2}}{x^2}

Then we integrate to get

{e^{ - {x^2}/2}}y = \int {{e^{ - {x^2}/2}}{x^2}dx}

We may try to solve the RHD integral by integration by parts. If we try directly we will find that we cannot integrate the exponential function, and integrating the x2 part will just increase the power. Here we will use a little trick and split the function in another way to get

\begin{gathered} I = \int {{e^{ - {x^2}/2}}{x^2}dx}  = \int {\underbrace {{e^{ - {x^2}/2}}x}_f \cdot \underbrace x_gdx}  = F \cdot g - \int {F \cdot g'dx}  \hfill \\   \left| \begin{gathered}   F = \int {{e^{ - {x^2}/2}}xdx}  \hfill \\   \quad \left| {\begin{array}{*{20}{c}}   {w =  - {x^2}/2} \\   {dw =  - xdx} \\   { - dw = xdx} \end{array}} \right. \hfill \\    =  - \int {{e^w}dw =  - {e^w} =  - {e^{ - {x^2}/2}},\quad g' = 1}  \hfill \\ \end{gathered}  \right. \hfill \\   I =  - {e^{ - {x^2}/2}}x + \int {{e^{ - {x^2}/2}}} dx \hfill \\ \end{gathered}

And here we are stuck because the integral cannot be solved with elementary functions. So our answer, for the moment, is

{e^{ - {x^2}/2}}y =  - {e^{ - {x^2}/2}}x + \int {{e^{ - {x^2}/2}}} dx

or

y = {e^{{x^2}/2}}\int {{e^{ - {x^2}/2}}} dx - x

All is not lost though, because say we want to have a solution that goes through (1, 2) and we want to know its value when x=2. We could write our solution as

y = {e^{{x^2}/2}}\int\limits_a^x {{e^{ - {x^2}/2}}dx}  - x

Where a is a constant. Next, we substitute our coordinates into the equation,

2 = {e^{1/2}}\int\limits_a^1 {{e^{ - {x^2}/2}}dx}  - 1

so

\frac{3}{{\sqrt e }} = \int\limits_a^1 {{e^{ - {x^2}/2}}dx}

So we need to find a way to find this value a. How to do this? Yet again all is not lost.  If you remember that the cumulative standard normal probability function is

ncf(x) = \frac{1}{{\sqrt {2\pi } }}\int\limits_{ - \infty }^x {{e^{ - {t^2}/2}}dt}

and most scientific calculators and mathematical software packages can calculate this (or something called the error function). So

\int\limits_a^x {{e^{ - {x^2}/2}}dx}  = \sqrt {2\pi } (ncf(x) - ncf(a))

This, by the way, allows us to write the solution to our differential equation as

y = {e^{{x^2}/2}}\sqrt {2\pi } (ncf(x) - ncf(a)) - x

Ok, so we do have a general solution, but yet again, say we need a particular solution that passes through a point (x0, y0)? We get

ncf(a) = ncf({x_0}) - \frac{{{x_0} + {y_0}}}{{{e^{{x_0}^2/2}}\sqrt {2\pi } }}

or in our case (1, 2), so

ncf(a) = ncf(1) - \frac{3}{{\sqrt {2\pi e} }}

So we have the particular solution

y = {e^{{x^2}/2}}\sqrt {2\pi } \left( {ncf(x) - ncf(1) + \frac{3}{{\sqrt {2\pi e} }}} \right) - x

Back to the question, what is y when x=2? Substituting 2 into our equation we get about 13.96 for y.

A general solution that will go through a point (x0, y0) will thus be

y = {e^{{x^2}/2}}\sqrt {2\pi } \left( {ncf(x) - ncf({x_0}) + \frac{{{x_0} + {y_0}}}{{{e^{{x_0}^2/2}}\sqrt {2\pi } }}} \right) - x

This can be tested with this Texas instruments Nspire file: ypxyisx2
or this Geogebra file.

Up a level : Differential Equations
Previous page : Homogenous differential equations - a more general type
Next page : Brine mixture, case 1, inflow=outflow, pure water inLast modified: Dec 28, 2023 @ 17:23