Chapter 7 Analytical Solutions: Solving ODEs Using Separation of Variables

7.1 Definitions

There are a wide variety of techniques for solving ODEs analytically, all of them are dependent upon the ODE taking on a certain form. Studying all of the techniques is well beyond the scope of this class. Instead, we will focus on one of the most common techniques encountered in the sciences. We have already seen how to solve pure-time differential equations (those in the form \(y'=f(t)\)); just anti-differentiate. In this section we will deal with separable differential equations.

A first-order ODE is separable if it can be written in the form \[y'=f(t)g(y).\] In words, a first-order ODE is separable if the right-hand side of the equation can be factored into a product of functions. One of the functions must depend only on \(t\), or be constant. The other function must depend only on \(y\), or be constant.

Examples

The differential equation \[y'=ty\] is separable, because it is already written in the form \(f(t)=t\), \(g(y)=y\).

The differential equation \[y'=\cos(y)t^2\] is also separable. Here we have \(f(t)=t^2\), \(g(y)=\cos(y)\).

The differential equation \[y'=ty+y\] is also separable, though it isn’t immediately obvious. If we factor a \(y\) on the right-hand side of the problem, we get \[y'=y(t+1)\] which is separable with \(f(t)=t+1\) and \(g(y)=y\). Sometimes a fair amount of algebra is required to separate an ODE.

The differential equation \[y'=t+y\] is not separable; there is no way to factor that right-hand side into a product of functions that depend only on \(t\) and \(y\).

Two special kinds of ODEs that we have already seen are always separable. Pure-time ODEs are always separable, because their right-hand side depends only on \(t\). For example, the differential equation \[y'=\sin(t)\] is separable with \(f(t)=\sin(t)\) and \(g(y)=1\) (remember that it is ok for either function to be constant).

Autonomous differential equations are also always separable, because their right-hand side depends only on \(y\). For example, the differential equation \[y'=y(1-y)\] is separable with \(f(t)=1\) and \(g(y)=y(1-y)\).

Since we can already solve pure-time differential ODEs, we will not spend any time on them in this section. Instead, we’ll focus on ODEs that are separable but non-autonomous, and autonomous differential equations. In fact, we’ll spend most of our time on autonomous differential equations.

Autonomous ODEs are powerful enough to warrant their own vocabulary. The term dynamics applies to all systems that change over time. ODEs always relate to rates of change and are thus associated with dynamics. However, \(y^{'} = g(y)\) is special. The rate of change is determined by the current state. The state of a system is the current value \(y(t)\). Here are a couple of examples: the population of bacteria changes at a rate proportional to the number of bacteria; the temperature of a hot cup of tea changes at a rate proportional to the temperature difference between the tea and the air. Models for those and a host of other applications are all autonomous differential equations. By contrast, the velocity (rate of change of height) of a ball tossed in the air does not change based upon its current height. The ODE modeling this scenario is non-autonomous.

The dynamics associated with \(y^{'} = g(y)\) provide a broad framework for modeling many real-world phenomena. As we move through the next few sections, we will look at some of the common models that are built using differential equations and notice that they are nearly all autonomous.

7.2 Motivating Examples

In this section we consider separable ODEs broadly. We’ll begin with a simple example, then point out the general principle for solving these kinds of ODEs, and then finally we’ll introduce a shorthand that is commonly used.

Consider solving the differential equation \[\frac{dy}{dt}=\frac{t}{y^2}.\] This differential equation is separable, with \(f(t)=t\) and \(g(y)=\frac{1}{y^2}\). We can re-write the problem as \[y^2\frac{dy}{dt} = t.\] This step, dividing by \(g(y)\) (in this case multiplying by \(y^2\)), is called separating variables.

Now we are ready to be clever. Remember, \(y\) is not a variable, \(y\) is the name of some function, and we really should be writing \(y(t)\). Similarly, \(\frac{dy}{dt}\) is also some unknown function of \(t\). Since both sides of the equality are functions, we can integrate them with respect to \(t\) and get \[\int y^2\frac{dy}{dt}\,dt=\int t\,dt.\] The integral on the right is easy to compute. The integral on the left is harder, because \(y\) is an unknown function of \(t\). We need to find some function, likely expressed in terms of \(y\), whose derivative is \(y^2\frac{dy}{dt}\). Fortunately, the chain rule and some clever thinking come to our rescue. The chain rule tells us that if \(y\) is an unknown function of \(t\) then \[\frac{d}{dt}\left[\frac13 y^3\right]=y^2\frac{dy}{dt}.\] Remember, the chain rule says to take the derivative like normal, and then an extra \(\frac{dy}{dt}\) pops out. With this in hand, we know that an anti-derivative of \(y^2\frac{dy}{dt}\) is \(\frac13 y^3\). Therefore, we can actually compute the integral on both side of our equation, remember our constants of integration, and get \[\frac{1}{3}y^3+C_1 = \frac{t^2}{2}+C_2.\] Combining the constants of integration gives us \[\frac{1}{3}y^3 = \frac{t^2}{2}+C_3,\] here \(C_3=C_2-C_1\).

Now we almost have an expression for \(y\) in terms of \(t\)! Multiply by 3, \[y^3=\frac{3}{2}t^2+3C_3,\] and now solve for \(y\), \[y=\sqrt[3]{\frac{3}{2}t^2+3C_3}.\] We might define \(C=3C_3\) to get the nice-looking solution \[y=\sqrt[3]{\frac{3}{2}t^2+C}.\] We can check and see that this really is the general solution to the ODE.

Let’s do another example. Consider solving \[\frac{dy}{dt}=6y, \text{ assuming } y>0.\] The assumption that \(y>0\) will help us later on. This equation is separable, with \(f(t)=6\) and \(g(y)=y\). First, we separate variables and get \[\frac{1}{y}\frac{dy}{dt}=6.\] We also could have divided the 6 to the left-hand side, the results would end up the same.

Now, we integrate both sides \[\int \frac{1}{y}\frac{dy}{dt}\,dt=\int 6\,dt.\] Again, the integral on the right is easy, but the integral on the left requires some thinking. Once again, the chain rule comes to the rescue. The chain rule tells us that \[\frac{d}{dt}\left[\ln(y)\right]=\frac{1}{y}\frac{dy}{dt}.\] Therefore, the antiderivative we seek is \(\ln(y)\) (since we assumed that \(y>0\), we don’t need an absolute value). With this in hand we have \[\ln(y)+C_1=6t+C_2.\] Combine the constants of integration, \[\ln(y)=6t+C_3,\] and exponentiate to solve for \(y\). \[y=e^{6t+C_3}.\] The solution above is correct, but not written in the most standard form. Typically, this solution gets written as \[y=e^{6t}e^{C_3}=Ce^{6t},\] where \(C=e^{C_3}\).

Note: The careful reader will notice that the correct anti-derivative of \(\frac{1}{y}\frac{dy}{dt}\) is \(\ln|y|+C_1\), and that the assumption \(y>0\) allows us to write \(\ln(y)\) instead of \(\ln|y|\). In many applications, assuming that \(|y|>0\) is quite natural, for instance, if \(y\) represents a population. For this course, when performing separation of variables, we will always assume that \(y>0\) and write \(\ln(y)\) instead of \(\ln|y|\). In a course entirely devoted to differential equations you will study how to eliminate this assumption, however, doing so is mostly an exercise in algebra and is not that informative.

7.3 General Framework

The key observation in both examples above was using the chain rule to anti-differentiate unknown functions in the form \(h(y)\frac{dy}{dt}\) where \(y\) is an unknown function of \(t\). In both cases we saw that the mulitplier of \(\frac{dy}{dt}\) saved us – we really only had to worry about anti-differentiating \(h(y)\) as if \(y\) were a variable. In fact, it is common to replace \(\frac{dy}{dt}\,dt\) with \(dy\), as if that were fraction multiplication, inside the integral when performing integration by parts. This helps us remember that 1) We need to get all \(y\)-terms to be multiplied by \(\frac{dy}{dt}\) and 2) once we have done so, we don’t need to worry about \(\frac{dy}{dt}\) anymore, we can just anti-differentiate as if \(y\) were a variable.

The steps to performing separation of variables are:

  1. Make sure your equation is separable, in the form \[\frac{dy}{dt}=f(t) g(y).\] It is best to use \(\frac{dy}{dt}\) instead of \(y'\) here, as it helps out later.

  2. Separate the variables, by dividing by \(g(y)\), though in practice this might look like multiplication. Now we have an equation in the form \[\frac{1}{g(y)}\frac{dy}{dt}=f(t)\] where every instance of the unknown function \(y\) is multiplied by \(\frac{dy}{dt}\).

  3. Integrate both sides of the equation. \[\int \frac{1}{g(y)}\frac{dy}{dt}\,dt = \int f(t)\,dt.\] Treat \(\frac{dy}{dt}\) and \(dt\) like a fraction, and write \[\int \frac{1}{g(y)}\,dy = \int f(t)\,dt,\] which helps us remember that the \(\frac{dy}{dt}\) is saving us, we really only need an anti-derivative for the expression in \(y\).

  4. Once the anti-derivatives are computed, solve for \(y\) using algebra.

7.4 Worked Examples

7.4.1 Example 1

Solve this IVP: \[u^{'} = \frac{2}{u}\ \text{ with } u(0) = 1.\] First, convert to \(\frac{du}{dt}\) notation, and separate the variables. \[u\frac{du}{dt} = 2.\] Next, integrate both sides. \[\int u\frac{du}{dt}\,dt = \int 2\,dt.\] Treat \(\frac{du}{dt}\) and \(dt\) like a fraction, to remind yourself that you really only have to anti-differentiate the \(u\) term. \[\int u\,du = \int 2\,dt.\]

Next, perform the anti-differentiation. \[\frac{u^2}{2}=2t+C_1\] We always end up with a constant of integration on both sides of the equation, and then we always immediately combine them. It is common to just put the constant on one side of the equation to save time.

Finally, solve for \(u\). \[u=\pm\sqrt{4t+2C_1},\] or \[u=\pm\sqrt{4t+C}\] if we let \(C=2C_1\).

We can see that there are two possible solutions for \(u\), \(u=+\sqrt{4t+C}\) and \(u=-\sqrt{4t+C}\). In order to satisfy our initial condition of \(u(0)=1\), we’ll have to choose \(u=+\sqrt{4t+C}.\)

Now, to determine \(C\) to satisfy our initial condtion:

\[1=u(0)= \sqrt{4\cdot 0 + C},\] \[1 = \sqrt{C},\] \[C = 1.\]

The specific solution for this IVP is

\[u(t) = \sqrt{4t + 1}.\]

7.4.2 Example #2

Solve this IVP: \[y^{'} = (y + 1)^{2}t^2,\quad y(2)=2\] First, convert to \(\frac{dy}{dt}\) notation, and then separate variables. \[\frac{1}{(y+1)^2}\frac{dy}{dt}=t^2.\]

Write an integral sign on both sides, and cancel the \(dt\)’s. \[\int \frac{1}{(y+1)^2}\frac{dy}{dt}\,dt=\int t^2\,dt .\] \[\int \frac{1}{(y+1)^2}dy=\int t^2\,dt .\]

Now, integrate both sides of the equation. The integral on the left can be done with a \(u\)-substitution, or, just use antiD. The integral on the right can also be done using antiD, but hopefully that isn’t necessary!

antiD(1/(y+1)^2~y)
## function (y, C = 0) 
## {
##     -1/(y + 1) + C
## }
## <environment: 0x0000018ea1566708>

\[\frac{-1}{y+1} = \frac{1}{3}t^3+C_1.\] Now, solve for \(y\). There is no R function to help with this. \[\frac{-1}{y+1} = \frac{t^3+3C_1}{3}.\] \[\frac{1}{y+1} = \frac{-t^3-3C_1}{3}.\] \[y+1 = \frac{3}{-t^3-3C_1}.\] \[y = \frac{3}{-t^3-3C_1}-1.\] If we want, we can simplify somewhat by setting \(C=3C_1\) and moving a negative sign to the numerator. \[y = \frac{-3}{t^3+C}-1.\] Now we have the general solution to the ODE. In order to solve the IVP, we use the initial condition to determine \(C\).

\[\begin{aligned} &2=y(2)=\frac{-3}{2^3+C}-1\\ &3=\frac{-3}{8+C}\\ &8+C=-1\\ &C=-9 \end{aligned}\] The solution to the IVP is \[y=\frac{-3}{t^3-9}-1.\]

7.4.3 Example: Bacterial Population Growth

7.4.3.1 Initial Value Problem

When a colony of bacteria is being established in a Petri dish, before the colony is running out of room to grow or nutrients to sustain it, the rate at which the population of the colony grows is proportional to the current population. If the population is large, then there are a lot of bacteria dividing, and thus there are many new bacteria being added to the population. If the current population is small, then there aren’t many bacteria that can possibly be dividing, and so there can’t be many new bacteria being added to the population. Let the population of the Petri dish at time \(t\) be \(P(t)\). Assume that we have established that the population of our Petri dish grows according to \[P^{'} = 0.25P\] Assume that time is measured in hours, and that after 1 hour the population of the Petri dish was 100 bacteria. Find a formula for \(P\).

First, write the ODE in \(\frac{dP}{dt}\) form, and separate variables. \[\frac{1}{P}\frac{dP}{dt}=0.25.\] Write an integral sign on both signs, and cancel the \(dt\)’s. \[\int\frac{1}{P}\frac{dP}{dt}dt=\int 0.25 dt.\] \[\int\frac{1}{P}dP=\int 0.25 dt.\] Now integrate both sides of the equation. Only write the constant of integration on one side of the equation, to save writing. As usual in this chapter, assume that \(P>0\) when it appears inside a natural logarithm so that we don’t need to take an absolute value of \(P\). \[\ln(P)=0.25t+C_1.\] Solve for \(P\). \[P=e^{0.25t+C_1}=Ce^{0.25t},\] where \(C=e^{C_1}\).

Now we can use our initial condition, \(P(1)=100\), to find the specific solution to this IVP.
\[100=P(1)=Ce^{0.25\cdot 1}= Ce^{0.25}=C\cdot 1.284\] So \[C=\frac{100}{1.284}=77.88.\] The specific solution to the IVP is \[P(t)=77.88e^{0.25t}.\]

7.4.3.2 Additional Insights

Once we have a formula for \(P(t)\) determined, we can answer a great variety of questions. For instance, how many bacteria will be in the dish at time \(t=20\) hours?

We can evaluate \(P(20)\) to get our answer. In R this would look like the following.

P=makeFun(77.88*exp(0.25*t)~t)
P(20)
## [1] 11558.42

There will be about 11558 bacteria in the dish at time \(t=20\) hours.

How many bacteria were there in the dish at the outset of the experiment? Assuming that the start of the experiment is time \(t=0\), we evaluate \(P(0)\) to find that there were approximately 77.88 bacteria in the dish at the outset of the experiment.

How long will it take for our colony to grow to 100,000 bacteria? We need to solve \[P(t)=100000\] \[77.88e^{0.25t}=100000\] for \(t\).

We can proceed algebraically if we desire. \[e^{0.25t}=\frac{100000}{77.88}=1284.03\] \[0.25t=\ln\left(1284.03\right)=7.158\] \[t=\frac{7.158}{0.25}=28.631.\] We can see that at time \(t=28.631\) hours, the bacteria population will reach 100,000.

Alternatively, we could use the findZeros command to solve \(P(t)-100000=0\).

findZeros(P(t)-100000~t)
##        t
## 1 28.631

7.4.4 Example: Cooling Engines

The engines on a C-130 heat up during flight. Once the plane lands, the engines are cooled by the surrounding air; they must return to below 175\(^\circ\)C before they can be restarted.

Let the temperature of the engines of the plane at time \(t\) (measured in minutes) be \(T(t)\). Assuming the ambient air temperature is 23\(^\circ\)C, one model for the temperature of the engines is \[T'=0.03(23 - T).\] Find a formula for \(T\), assuming that \(t=0\) corresponds to the time the plane is parked, and that when the plane was parked the temperature of the engines was 600\(^\circ\)C.

First, write the ODE with \(\frac{dT}{dt}\) notation, and separate variables. \[\frac{1}{23-T}\frac{dT}{dt}=0.03.\]

Next, write an integral sign on both sides, and cancel the \(dt\)’s. \[\int \frac{1}{23-T}\frac{dT}{dt}\,dt=\int 0.03\,dt.\] \[\int \frac{1}{23-T}dT=\int 0.03\,dt.\]

Now, actually perform the integration on each side. We can use \(u\)-substitution on the left-hand integral, or we can use antiD. Only write the constant of integration on the right-hand side, to save writing. \[-\ln(23 - T) = 0.03 t + C_1.\]

Now, solve for \(T\) using algebra. \[\begin{aligned} &\ln(23 - T) = -0.03 t + C_1\\ &23 - T = e^{-0.03 t + C_1}\\ &- T = e^{-0.03 t + C_1}-23\\ &T = -e^{-0.03 t + C_1}+23\\ &T = -Ce^{-0.03 t }+23.\end{aligned}\] where \(C=e^{C_1}\).

We have the general solution for \(T\). Our initial condition is \(T(0)=600\). We can use this information to solve for \(C\) and obtain the specific solution to the IVP.

\[\begin{aligned} &600 = T(0) = -Ce^{0.03\cdot 0} + 23\\ &600 = -C + 23\\ &577 = -C \\ &C = -577. \end{aligned}\]

The specific solution to our IVP is \[T=577e^{-0.03 t}+23.\]

7.4.4.1 Additional Insights

What will the temperature of the engines be 15 minutes after landing?

We can evaluate \[T(15)=577 e^{-0.03 \cdot 15}+23 \approx 390.9^\circ\text{C}.\] How long will it take the engines to return to starting temperature, 175\(^\circ\)C?

We must solve for the time \(t\), that produces a temperature of 175\(^\circ\)C. \[\begin{aligned} &175=T(t)=577e^{-0.03 t}+23\\ &152=577 e^{-0.03 t}\\ & 0.26 = e^{-0.03 t}\\ &-1.33 =-0.03 t\\ & 44.47 = t\\ \end{aligned}\]

It will take approximately 44.47 minutes for the engines to return to operational temperature.

We could also have solved this problem using findZeros, by solving \(T(t)-175 = 0\).

findZeros(577*exp(-0.03*t)+23 -175 ~t)
##        t
## 1 44.465

7.5 Exercises

Solve the following IVPs. Provide the general solution, the specific solution for the initial condition, and a plot of the specific function on a representative domain.

1) ODE: \[y^{'} = y\] IC: \[y(0) = 2\]
2) ODE: \[u^{'} = \frac{u}{50}\] IC: \[u(0) = - 1\]
3) ODE: \[w^{'} = - 2w\] IC: \[w(1) = 3\]
4) ODE: \[z^{'} = 3z\] IC: \[z(0) = - 4\]
5) ODE: \[w^{'} = \frac{1}{w}\] IC: \[w(0) = 4\] \(t \geq - 8\) is required, why?
6) ODE: \[u^{'} = e^{- u}\] IC: \[u(2) = 0\] \(t > 1\) is required, why?
7) ODE: \[y^{'} = (y + 1)^{2}\] IC: \[y(0) = - 3\] \(t \neq \ ?\) is required
8) ODE: \[z^{'} = z + 1\] IC: \[z(1) = 0\]
9) ODE: \[y^{'} = 2\sqrt{y}\] IC: \[y(0) = 2\] Are both solutions reasonable?
10) ODE: \[w^{'} = 4\] IC: \[w(0) = 0\]
11) ODE: \[z^{'} = z^{2}\] IC: \[z(0) = 2\] \(t < \ ?\) is required
12) ODE: \[u^{'} = 0.01u\] IC: \[u(0) = 5000\]
13) ODE: \[z^{'} = \frac{1}{z^{2}}\] IC: \[z(0) = 2\]