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)t2 is also separable. Here we have f(t)=t2, 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 dydt=ty2. This differential equation is separable, with f(t)=t and g(y)=1y2. We can re-write the problem as y2dydt=t. This step, dividing by g(y) (in this case multiplying by y2), 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, dydt 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 ∫y2dydtdt=∫tdt. 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 y2dydt. 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 ddt[13y3]=y2dydt. Remember, the chain rule says to take the derivative like normal, and then an extra dydt pops out. With this in hand, we know that an anti-derivative of y2dydt is 13y3. Therefore, we can actually compute the integral on both side of our equation, remember our constants of integration, and get 13y3+C1=t22+C2. Combining the constants of integration gives us 13y3=t22+C3, here C3=C2−C1.
Now we almost have an expression for y in terms of t! Multiply by 3, y3=32t2+3C3, and now solve for y, y=3√32t2+3C3. We might define C=3C3 to get the nice-looking solution y=3√32t2+C. We can check and see that this really is the general solution to the ODE.
Let’s do another example. Consider solving dydt=6y, 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 1ydydt=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 ∫1ydydtdt=∫6dt. 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 ddt[ln(y)]=1ydydt. 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)+C1=6t+C2. Combine the constants of integration, ln(y)=6t+C3, and exponentiate to solve for y. y=e6t+C3. The solution above is correct, but not written in the most standard form. Typically, this solution gets written as y=e6teC3=Ce6t, where C=eC3.
Note The careful reader will notice that the correct anti-derivative of 1ydydt is ln|y|+C1, 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 do 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)dydt where y is an unknown function of t. In both cases we saw that the mulitplier of dydt 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 dydtdt 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 dydt and 2) once we have done so, we don’t need to worry about dydt anymore, we can just anti-differentiate as if y were a variable.
The steps to performing separation of variables are:
Make sure your equation is separable, in the form dydt=f(t)g(y). It is best to use dydt instead of y′ here, as it helps out later.
Separate the variables, by dividing by g(y), though in practice this might look like multiplication. Now we have an equation in the form 1g(y)dydt=f(t) where every instance of the unknown function y is multiplied by dydt.
Integrate both sides of the equation. ∫1g(y)dydtdt=∫f(t)dt. Treat dydt and dt like a fraction, and write ∫1g(y)dy=∫f(t)dt, which helps us remember that the dydt is saving us, we really only need an anti-derivative for the expression in y.
Once the anti-derivatives are computed, solve for y using algebra.
7.4 Worked Examples
7.4.1 Example 1
Solve this IVP: u′=2u with u(0)=1. First, convert to dudt notation, and separate the variables. ududt=2. Next, integrate both sides. ∫ududtdt=∫2dt. Treat dudt and dt like a fraction, to remind yourself that you really only have to anti-differentiate the u term. ∫udu=∫2dt.
Next, perform the anti-differentiation. u22=2t+C1 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=±√4t+2C1, or u=±√4t+C if we let C=2C1.
We can see that there are two possible solutions for u, u=+√4t+C and u=−√4t+C. In order to satisfy our initial condition of u(0)=1, we’ll have to choose u=+√4t+C.
Now, to determine C to satisfy our initial condtion:
1=u(0)=√4⋅0+C, 1=√C, C=1.
The specific solution for this IVP is
u(t)=√4t+1.
7.4.2 Example #2
Solve this IVP: y′=(y+1)2t2,y(2)=2 First, convert to dydt notation, and then separate variables. 1(y+1)2dydt=t2.
Write an integral sign on both sides, and cancel the dt’s. ∫1(y+1)2dydtdt=∫t2dt. ∫1(y+1)2dy=∫t2dt.
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!
## function (y, C = 0)
## {
## -1/(y + 1) + C
## }
## <environment: 0x000002a2a16c0588>
−1y+1=13t3+C1.
Now, solve for y. There is no R
function to help with this.
−1y+1=t3+3C13.
1y+1=−t3−3C13.
y+1=3−t3−3C1.
y=3−t3−3C1−1.
If we want, we can simplify somewhat by setting C=3C1 and moving a negative sign to the numerator.
y=−3t3+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.
2=y(2)=−323+C−13=−38+C8+C=−1C=−9 The solution to the IVP is y=−3t3−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 dPdt form, and separate variables. 1PdPdt=0.25. Write an integral sign on both signs, and cancel the dt’s. ∫1PdPdtdt=∫0.25dt. ∫1PdP=∫0.25dt. 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+C1. Solve for P. P=e0.25t+C1=Ce0.25t, where C=eC1.
Now we can use our initial condition, P(1)=100, to find the specific solution to this IVP.
100=P(1)=Ce0.25⋅1=Ce0.25=C⋅1.284
So
C=1001.284=77.88.
The specific solution to the IVP is
P(t)=77.88e0.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.
## [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.88e0.25t=100000 for t.
We can proceed algebraically if we desire. e0.25t=10000077.88=1284.03 0.25t=ln(1284.03)=7.158 t=7.1580.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.
## 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∘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∘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∘C.
First, write the ODE with dTdt notation, and separate variables. 123−TdTdt=0.03.
Next, write an integral sign on both sides, and cancel the dt’s. ∫123−TdTdtdt=∫0.03dt. ∫123−TdT=∫0.03dt.
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.03t+C1.
Now, solve for T using algebra. ln(23−T)=−0.03t+C123−T=e−0.03t+C1−T=e−0.03t+C1−23T=−e−0.03t+C1+23T=−Ce−0.03t+23. where C=eC1.
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.
600=T(0)=−Ce0.03⋅0+23600=−C+23577=−CC=−577.
The specific solution to our IVP is T=577e−0.03t+23.
7.4.4.1 Additional Insights
What will the temperature of the engines be 15 minutes after landing?
We can evaluate T(15)=577e−0.03⋅15+23≈390.9∘C. How long will it take the engines to return to starting temperature, 175∘C?
We must solve for the time t, that produces a temperature of 175∘C. 175=T(t)=577e−0.03t+23152=577e−0.03t0.26=e−0.03t−1.33=−0.03t44.47=t
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.
## 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′=u50 | IC: | u(0)=−1 | |
3) | ODE: | w′=−2w | IC: | w(1)=3 | |
4) | ODE: | z′=3z | IC: | z(0)=−4 | |
5) | ODE: | w′=1w | IC: | w(0)=4 | t≥−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≠ ? is required |
8) | ODE: | z′=z+1 | IC: | z(1)=0 | |
9) | ODE: | y′=2√y | IC: | y(0)=2 | Are both solutions reasonable? |
10) | ODE: | w′=4 | IC: | w(0)=0 | |
11) | ODE: | z′=z2 | IC: | z(0)=2 | t< ? is required |
12) | ODE: | u′=0.01u | IC: | u(0)=5000 | |
13) | ODE: | z′=1z2 | IC: | z(0)=2 | |
14) | ODE: | w′=w2+w+1 | IC: | w(0)=1 | A solution exists, but what is the issue here? |
15) | ODE: | w′=1w2+w+1 | IC: | w(0)=1 | A solution exists, but what is the issue here? |