2.3: Nonhomogeneous Equations

Open In Colab

Reading: Notes on Diffy Q’s Section 2.5 and Section 2.6

An Initial Guess for Nonhomogeneous Equations


So far we have been using patterns recognized in wisely guessing the form of solutions to homogeneous second order differential equations of the form \(ay''+by'+cy = 0\).
Can we adjust our guesses to handle nonhomogeneous differential equations as well?

Question 1:


Find a solution to the following nonhomogeneous differential equation: \[\frac{d^2x}{dt^2}+10\frac{dx}{dt}+9x=18.\]

What is your best guess for a function whose second derivative plus 10 times its first derivative plus 9 times the function itself sum to 18? Test out your guess to see if it works. If it doesn’t work keep trying.

Solution to Question 1:







A Particular Solution for a Nonhomogeneous Equation


The solution you found in the previous question is called the particular solution to the nonhomogeneous differential equation it is not the general solution. For now we will focus on how we can find the particular solution by wisely guessing their general form based on the nonhomogeneous part of the differential equation. We will soon combine what we know about the homogeneous case and particular solutions to find general solutions.

Question 2:


Find a solution to the following nonhomogeneous differential equation: \[\frac{d^2x}{dt^2}+10\frac{dx}{dt}+9x=18t.\]

What is your best guess? Test out your guess to see if it works. If it doesn’t work keep trying.

Solution to Question 2:







Question 3:


Based on the previous examples, what would be a good guess for the general form of the particular solution to \[\frac{d^2x}{dt^2}+10\frac{dx}{dt}+9x=18t^3.\]

Your guess should have depend on constants whose values you do not need to determine for this example.

Solution to Question 3:







Question 4:


Sean and Paula are trying to find the particular solution to

\[\frac{d^2x}{dt^2}+10\frac{dx}{dt}+9x=85\sin(2t).\]

Sean guesses \(x(t)=A\sin(2t)\) for the particular solution and Paula guesses \(x(t)=B\cos(2t)\).

Question 4a:


Do you think these are reasonable guesses? Explain why or why not.

Solution to Question 4a:







Question 4b:


For each of their guesses, can you find a value of \(A\) or \(B\) such that their guess is a solution? If yes, write down the general solution. If no, come up with a different guess for the particular solution and show that your guess is correct.

Solution to Question 4b:







Optional: Solving Question 4b with Python


We use our guess of \(x_{p}(t) =\) ?? from Question 4b in the code cell below.

  • First we import required libraries.
  • Then we define symbols.
  • Enter a symnbolic formula for \(x_p(t)\) for x in the code below.
  • Compute first and second derivatives.
  • Plug \(x_p\), \(x'_p\), and \(x''_p\) into the left side of the differential equation and group terms.
# STUDENT TO_DO: Replace each ?? with an appropriate expression

import numpy as np
import sympy as sym

t, x, A, B = sym.symbols('t, x, A, B')  # Creating symbols

x = ??  # Particular solution

first = x.diff(t,1)  # find formula for x'_p
second = x.diff(t,2)  # find formula for x''_p

sym.simplify(??)  # simplify left side of diff eq

Interpreting Simplified Output


The output above tells us that

\[x''_p + 10x'_p + 9x_p = (??)\sin{(2t)} + (??) \cos{(2t)} = 85\sin{(2t)} + 0 \cos{(2t)}.\]

Thus, to solve for \(A\) and \(B\), we can solve the system of linear equations

\[\begin{array}{rcrcr} ??A & - & ??B & = & 85\\ ??A & + & ??B & = & 0 \end{array}\]

We use the linalg.solve() function from SymPy to solve this system. See Solving Systems with linalg.solve more details.

# STUDENT TO_DO: Replace each ?? with an appropriate number

# Enter coefficient matrix 
A = np.array([[??, ??],
              [??, ??]])

# Enter vector of constants on right side
b = np.array([[??],[??]])

# Solve Ax=b and store solution in x
x = np.linalg.solve(A,b)

# Print solution to the screen
print("The solution to the system is \n", x)

Interpreting Output: Expressing a Final Answer


From the output above we see that \(A=??\) and \(B=??\), thus the particular solution is

\[x_p = A\sin{(2t)}+B\cos{(2t)} = ??\sin{(2t)} + ?? \cos{(2t)}.\]

Question 5:


Consider the nonhomogeneous differential equation \[\frac{d^2x}{dt^2}+25x=10\cos(5t).\]

Question 5a:


Suppose you wish to find the particular solution to this differential equation. Explain why a guess of the form \(x(t) = A\cos(5t) + B\sin(5t)\) is doomed to fail.

Solution to Question 5a:







Question 5b:


Nevertheless, explain why your particular solution must have terms that look like \(\cos(5t)\) and \(\sin(5t)\).

Solution to Question 5b:







Question 5c:


For an unknown differentiable function \(f(t)\), write down the first and second derivatives of \(tf(t)\), what do you notice?

Solution to Question 5c:







Question 5d:


Explain why a guess of \(x(t) = At\cos(5t)\) is insufficient to find the particular solution.

Solution to Question 5d:







Question 5e:


Use the guess \(\color{tomato}{x(t) = t(A\cos(5t) + B\sin(5t))}\) to find a particular solution to the above equation.

Solution to Question 5e:







Optional: Solving Question 5e with Python


We use our guess of \(x_p(t) = t(A\cos(5t) + B\sin(5t))\) in the code cell below.

  • First we import required libraries.
  • Then we define symbols.
  • Enter a symnbolic formula for \(x_p(t)\) for x in the code below.
  • Compute first and second derivatives.
  • Plug \(x_p\), \(x'_p\), and \(x''_p\) into the left side of the differential equation and group terms.
# STUDENT TO_DO: Replace each ?? with an appropriate expression

#import numpy as np  # already imported earlier
#import sympy as sym  # already imported earlier

t, x, A, B = sym.symbols('t, x, A, B')  # Creating symbols

x = ??  # Particular solution

first = x.diff(t,1)  # find formula for x'_p
second = x.diff(t,2)  # find formula for x''_p

sym.simplify(??)  # simplify left side of diff eq

Interpreting Simplified Output


The output above tells us that

\[x''_p + 25 x_p = (??)\sin{(5t)} + (??) \cos{(5t)} = 0\sin{(5t)} + 10 \cos{(5t)}.\]

Thus, to solve for \(A\) and \(B\), we can solve the system of linear equations

\[\begin{array}{rcrcr} ??A & - & ??B & = & ??\\ ??A & + & ??B & = & ?? \end{array}\]

We use the linalg.solve() function from SymPy to solve this system. See Solving Systems with linalg.solve more details.

#import numpy as np  # already imported earlier

# STUDENT TO_DO: Replace each ?? with an appropriate number

# Enter coefficient matrix 
A = np.array([[??, ??],
              [??, ??]])

# Enter vector of constants on right side
b = np.array([[??],[??]])

# Solve Ax=b and store solution in x
x = np.linalg.solve(A,b)

# Print solution to the screen
print("The solution to the system is \n", x)

Interpreting Output: Expressing a Final Answer


From the output above we see that \(A=??\) and \(B=??\), thus the particular solution is

\[x_p = At\cos{(5t)}+Bt\sin{(5t)} = ??t\cos{(5t)} + ?? t\sin{(5t)}.\]

Forcing Functions with Resonance


The previous exercise is an example of resonance, which occurs when an external force has the same properties (such as frequency) as the general homogeneous solution. Practically speaking, when the homogeneous and nonhomogeneous parts of the differential equation have resonance this creates a huge increase in energy (that may even cause a bridge to collapse).

Question 6:


In each example, choose the words (does or does not) to indicate whether the nonhomogeneous differential equation has resonance.


  1. \(x''+25x=10\cos{(5t)}\) (does or does not) have resonance with the homogeneous solution \(x_H = C_1\cos{(5t)}+ C_2 \sin{(5t)}\).



  1. \(x''+25x=10e^{5t}\) (does or does not) have resonance with the homogeneous solution \(x_H = C_1\cos{(5t)}+ C_2 \sin{(5t)}\).



  1. \(x''-3x'-10x=10\cos(5t)\) (does or does not) have resonance with the homogeneous solution \(x_H = C_1e^{5t}+ C_2 e^{-2t}\).



  1. \(x''-3x'-10x=10e^{5t}\) (does or does not) have resonance with the homogeneous solution \(x_H = C_1e^{5t}+ C_2 e^{-2t}\).



  1. \(x''+2x'+ 17x=6e^{-t} \sin{(4t)}\) (does or does not) have resonance with the homogeneous solution \(x_H = C_1e^{-t}\cos{(4t)}+ C_2 e^{-t}\sin{(4t)}\).



  1. \(x''+2x'+ 17x=6 \sin{(4t)}\) (does or does not) have resonance with the homogeneous solution \(x_H = C_1e^{-t}\cos{(4t)}+ C_2 e^{-t}\sin{(4t)}\).

Solution to Question 6:




Edit the text for each part above.



Adjusting the Guess for Resonance


Whenever resonance is present between the homogeneous solution and nonhomogeneous forcing function, we can adjust our initial guess by multiplying by a factor of \(t\). For example, since \(x''+25x=10\cos(5t)\) has resonance our guess for the particular solution is

\[x_p = {\color{tomato}{\mathbf{t}}} \big( A\cos{(5t)}+ B \sin{(5t)} \big)=A{\color{tomato}{\mathbf{t}}}\cos{(5t)}+ B{\color{tomato}{\mathbf{t}}} \sin{(5t)}.\]

Question 7:


For each of the examples in the previous question where there was resonance, give the initial guess for the particular solution. Do not solve for the values of the undetermined coefficients, just enter a formula for a reasonable guess that would no longer have resonance.

Solution to Question 7:


  1. \(x_p =\) ??



  1. \(x_p =\) ??



  1. \(x_p =\) ??



  1. \(x_p =\) ??



  1. \(x_p =\) ??



  1. \(x_p =\) ??




Question 8:


What would be a good guess for the general form of the particular solution to \[ \frac{d^2y}{dt^2}-6\frac{dy}{dt}+9y=5e^{3t} \mbox{?}\] Do not find the values of the undetermined coefficients.

Solution to Question 8:







Question 9:


What would be a good guess for the general form of the particular solution to \[\frac{d^2y}{dt^2}-6\frac{dy}{dt}+9y=5e^{3t}\cos{(2t)} \mbox{?}\] Do not find the values of the undetermined coefficients.

Solution to Question 9:







Question 10:


What would be a good guess for the general form of the particular solution to \[ \frac{d^2y}{dt^2}-6\frac{dy}{dt}+9y=5t^2e^{3t}\cos{(2t)} \mbox{?}\] Do not find the values of the undetermined coefficients.

Solution to Question 10:







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.