1.5: Separable Differential Equations

Open In Colab

Reading: Notes on Diffy Q’s Section 1.3

General Solutions and Initial Value Problems


We can solve a differential equation of the form

\[ \frac{dy}{dt} = 6t^2 \]

since the solution to the differential equation are all functions \(y\) that have \(\dfrac{dy}{dt} = 6t^2\). Thus, \(y\) must be an antiderivative of \(6t^2\),

\[ y= \int \frac{dy}{dt} \ dt = \int 6t^2 dt = 2t^3 + C.\]

  • We say \(y=2t^3+C\) is the general solution to the differential equation. The general solution gives all possible solutions to the original differential equation.
  • If we are given additional information such as an initial condition \(y(t_1)=y_1\), then we get a unique solution.

For example, if we are given that \(\dfrac{dy}{dt} = 6t^2\) and \(y(2)=10\), first we find a general solution, and then we plug the initial condition into the general solution and solve for the general constant \(C\):

\[ y(2)=2(2)^3+C=16+C=10.\]

Thus, the solution will pass through the point \((2,10)\) only if \(C=-6\). The solution to the initial value problem (IVP) is \[ y=2t^3-6.\]

Plotting Solutions


  • Run the code cell below to plot solutions.
  • There is nothing to edit in the code cell.
  • Hit play and you are ready to go!
import numpy as np
import matplotlib.pyplot as plt

# Using Numpy to create an array t
# from t=-3 to t=3 with steps of 0.05
t = np.arange(-3, 3, 0.05)
z = np.ones(10)  

# general solutions
y = 2*t**3 - 6
plt.plot(t, y, color='r', label='C=-6')  # IVP solution

for i in range(0, 9):
    z = 2*t**3 - 50 + 10 * i 
    plt.plot(t, z, color='b')
pass

# Setting range of y-axis
plt.ylim(-60, 60)

# Adding the initial condition y(2)=10
plt.plot(2, 10, marker = "o", markersize = 8, color = 'k')

# Naming the x-axis, y-axis and the whole graph
plt.xlabel("t")
plt.ylabel("y")
plt.title("General Solutions")
plt.grid()

# Adding legend, which helps us recognize the curve according to it's color
plt.legend()
  
# To load the display window
plt.show()

Differential Equations Independent of the Dependent Variable


Differential equations of the form \(\dfrac{dy}{dt} = f(t)\) are a very special case since the derivative does not depend on the dependent variable. We have seen these differential equations are antiderivatives in disguise, and we can find a general solution by integrating both sides with respect to the independent variable (\(t\) in this case):

\[y = \int f(t) \, dt.\]

Question 1:


Can we apply the same method to solve an autonomous differential equation such as \(\frac{dy}{dt} = 0.2y\)? Explain what looks wrong with each of the possible solution strategies below.

  1. \(\displaystyle \int \frac{dy}{dt} \ dt = \int 0.2y \ dt\)

  2. \(\displaystyle \int \frac{dy}{dt} \ dy = \int 0.2y \ dy\)

  3. \(\displaystyle \int \frac{dy}{dt} \ dt = \int 0.2y \ dy\)

Solution to Question 1:







Finding the Solutions to Autonomous Differential Equations


As we can see from the question 1, solving an autonomous differential equation is not as direct as applying the same operation to both sides (integration with respect to \(t\)). However, we can apply the “reverse the chain rule” to solve an autonomous differential equation. Recall the chain rule:

\[ \frac{d}{dt} \big[ f \big( y(t) \big) \big] = f' \big( y(t) \big) \cdot y'(t)\]

Question 2:


Using the chain rule find a formula for \(\frac{d}{dt} \left( \ln{P} \right)\), where \(P\) is shorthand for \(P(t)\).

Solution to Question 2:







A Method for Reversing the Chain Rule


Now let’s try to develop a technique for solving an autonomous differential equation by applying (or rather by undoing) the chain rule. Below is an outline of a method to find the analytic solutions to some special types of differential equations called separable differential equations.

Question 3:


For a particular species of fish in a lake, the differential equation

\[ \frac{dP}{dt} = 0.2P\]

models the rate of change of the fish population \(P\) (measured in thousands of fish) \(t\) years from now. For now assume that \(P > 0\). This assumption corresponds to the population growth context, and it will make the algebra easier and hence the underlying idea clearer.

Follow the steps below to find a general solution to the differential equation.

Question 3a:


Divide both sides of \(\dfrac{dP}{dt}=0.2P\) by \(P\).

Solution to Question 3a:







Question 3b:


Replace \(\dfrac{1}{P}\dfrac{dP}{dt}\) with \(\left[ \ln(P)\right]'\).

Solution to Question 3b:







Question 3c:


Write integrals with respect to \(t\) on both sides.

Solution to Question 3c:







Question 3d:


Apply the Fundamental Theorem of Calculus to integrate both sides.

Solution to Question 3d:







Question 3e:


Solve for \(P\) (and remember that \(P\) is actually a function, \(P(t)\)).

Solution to Question 3e:







Question 3f:


Show that \(P\) can be written as \(P(t) = ke^{0.2t}\).

Solution to Question 3f:







Generalizing the Reverse Chain Rule


The end result, \(\displaystyle P(t)=ke^{0.2t}\) is called the general solution because it represents all possible functions that satisfy the differential equation. We can use the general solution to find any particular solution, which is a solution that corresponds to a given initial condition.

Question 4:


Use the same technique to find the general solution to \(\dfrac{dy}{dt}=\dfrac{t}{3y^2}\). The first step (dividing both sides by \(\frac{1}{3y^2}\)) is done for you below. Finish the rest of the process to find a general solution to the differential equation

\[3y^2\frac{dy}{dt}=t.\]

Solution to Question 4:







Question 5:


In practice, we often circumvent explicit use of the chain rule and instead use a shortcut to more efficiently find the general solution. The shortcut involves treating the derivative \(\frac{dy}{dt}\) as a ratio and “separating” the \(dy\) and \(dt\).

In the table below, follow the instructions to see how the shortcut works, using again the equation \(\displaystyle\frac{dP}{dt} = 0.2P\).

Question 5a:


“Separate” the \(dP\) from the \(dt\) so that \(dP\) and \(P\) are on the same side.

  • Keep in mind \(\frac{dP}{dt}\) is NOT a fraction.
  • We are abusing the notation for the derivative little bit.
  • In practice, this works due to the chain rule that we illustrated in an earlier example.
  • If there are \(t\)’s in the equation they must go on the same side as \(dt\) (if possible).

Solution to Question 5a:







Question 5b:


Integrate both sides of the equation.

  • If two expressions are equal, then performing the same operation on both sides preserves the equality.
  • However, we are integrating with respect to different variables on each side of the equation.
  • Thus, this step is also not technically a correct. We are abusing notation a little bit.
  • In reality, we are reversing the chain rule.
  • Integrate one side with respect to \(P\) and the other with respect to \(t\).

Solution to Question 5b:







Question 5c:


Using algebra, express your answer in explicit form \(P(t)=\underline{\hskip1cm}\)

Solution to Question 5c:







Question 6:


Use the shortcut method above to find the general solution to \(\dfrac{dy}{dt}=\dfrac{t}{3y^2}\).

Solution to Question 6:







Checking Your Solution with Python


In question 6 you should have found that a general solution to \(\dfrac{dy}{dt}=\dfrac{t}{3y^2}\) is \(\displaystyle y= \sqrt[3]{\frac{1}{2} t^2 +C}\).

Let’s check that our solution is correct using Python.

import sympy as sym  # import sympy, we use the abbreviation sym

t, y, C = sym.symbols('t, y, C')  # Creating t, y and C as symbols

y = sym.cbrt(1/2 * t**2 + C)

dy = sym.diff(y,t) # Use diff from sympy library to differentiate y with respect to t

check = t / (3 * y**2)
print("The left side is dy/dt = ", sym.simplify(dy), 
      "\n \n The right side is ", sym.simplify(check))

Identifying Where You Made an Error


The left and right sides should be equivalent expressions. If the output from the code cell above did not have both sides equal to each other, then we made a mistake somewhere in the process:

  • Did we integrate the expression of \(y\) correctly?
  • Did we integrate the expression of \(t\) correctly?
  • Did we solve for \(y\) correctly?
# checking integration with respect to y

t, y = sym.symbols('t, y')  # Creating t, y and as symbols
sym.integrate(3 * y**2, y)
# checking integration with respect to t

sym.integrate(t, t)

Identifying Separable Differential Equations


A differential equation is called separable if it can be written in the form

\[\frac{dy}{dx}=p(x,y)=f(x)g(y).\]

For example, the differential equation \(\dfrac{dy}{dt}=\dfrac{t}{3y^2}\) is separable since it can be written as

\[\frac{dy}{dt}=(t)\left( \frac{1}{3y^2} \right).\]

Question 7:


Decide whether the differential equation is separable. If so, separate it into the form \(\dfrac{1}{g(y)} dy = f(x) dx\).

Question 7a:


\(y' = 3x+y^2\)

Solution to Question 7a:







Question 7b:


\(\displaystyle \frac{dy}{dt} = t^2y+ty\)

Solution to Question 7b:







Question 7c:


\(\displaystyle \frac{dz}{dw} = e^{z+w}\)

Solution to Question 7c:







Question 7d:


\(y'=\ln{(xy)}\)

Solution to Question 7d:







Question 7e:


\(\displaystyle \frac{dy}{dx}-xy =0\)

Solution to Question 7e:







Question 8:


Solve the initial value problem. To solve an IVP one first must find the general solution and then use the initial condition to find the particular solution corresponding to the initial condition.

Question 8a:


\(z' = \dfrac{qz}{z^2+1}\), \(z(2)=1\)

Solution to Question 8a:







Question 8b:


\(\dfrac{dx}{dt}= \dfrac{x\ln{x}}{t}\), \(x(1)=6\)

Solution to Question 8b:







Question 8c:


\(\dfrac{y'}{x}= \dfrac{\sin{(x^2)}}{y}\), \(y(0)=3\)

Solution to Question 8c:







Question 9:

Verify and/or check your answers to each part of question 8 using Python.
### Solution to Question 9:





Complete the Python cells below.


# Check Solution to Question 8a:

??, ??  = sym.symbols('??, ??')  # What are the symbols

z = ??  # Enter the formula of your solution in 8s

dz = sym.diff(??, ??)  # Compute derivative of solution

check = ??  # Enter a formula to check your answer

print("The left side is ?? = ", sym.simplify(??), 
      "\n \n The right side is ", sym.simplify(??))
# Check Solution to Question 8b:

??, ??  = sym.symbols('??, ??')  # What are the symbols

x = ??  # Enter the formula of your solution in 8b

dx = sym.diff(??, ??)  # Compute derivative of solution

check = ??  # Enter a formula to check your answer

print("The left side is ?? = ", sym.simplify(??), 
      "\n \n The right side is ", sym.simplify(??))
# Check Solution to Question 8c:

??, ??  = sym.symbols('??, ??')  # What are the symbols

y = ??  # Enter the formula of your solution in 8c

dy = sym.diff(??, ??)  # Compute derivative of solution

check = ??  # Enter a formula to check your answer

print("The left side is ?? = ", sym.simplify(??), 
      "\n \n The right side is ", sym.simplify(??))

Question 10:


Solve the initial value problem \[\frac{dy}{dt}=\frac{t}{y}, \ \ \ \ \ y(2)=-1\]

  1. For what values of \(t\) is your solution valid? Why?

  2. Check to see that your particular solution “fits” the differential equation by substituting the solution and its derivative into the original differential equation.

Solution to Question 10:







Question 11:


Complete the two lines with ?? in the first Python code cell below to plot the slope field and your solution from question 10a to check your work.

Solution to Question 11:





Complete the first code cell below and then run the next two code cells (without any edits).


# To plot right half of the solution for t > 0
tsol1 = np.linspace(2, 10, 200)  
# Edit the line below
fsol1 = np.sqrt(??)  # enter formula of your solution

# To plot left half of the solution for t < 0
tsol2 = np.linspace(-10, -2, 200)  # range of ind variable
# Edit the line below
fsol2 = -1 * np.sqrt(??)  # enter formula of your solution
!pip install git+https://github.com/CU-Denver-MathStats-OER/ODEs
from IPython.display import clear_output
clear_output()
# Nothing to edit in this cell!

#import matplotlib.pyplot as plt
import math
from utils.ode_tols import slope_field

# Setup the grid
t = np.linspace(-10, 10, 21)  # np.linspace(initial, end, number_values)
x = np.linspace(-10, 10, 21)  # np.linspace(initial, end, number_values)

# Setup the differential equation
def diffeq(x, t):
    return t / x # Use t and x for ind and dep variables

# Plot the slope field and solutions
slope_field(t, x, diffeq)
plt.plot(tsol1, fsol1, color='b')
plt.plot(tsol2, fsol2, color='r')

Question 12:


Even though \(\dfrac{dy}{dt}\) is undefined when \(y=0\), the solution function can be defined such that \(y(2)=0\). What should the graph of this solution look like in the slope field?

Solution to Question 12:







Creative Commons License Information


Creative Commons License
Exploring Differential Equations by Adam Spiegler is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at https://github.com/CU-Denver-MathStats-OER/ODEs and original content created by Rasmussen, C., Keene, K. A., Dunmyre, J., & Fortune, N. (2018). Inquiry oriented differential equations: Course materials. Available at https://iode.sdsu.edu.