Differential Equations

Second Order Differential Equations<!-- --> | Differential Equations

Second Order Differential Equations

Sharan Sajiv Menon - September 7th, 2021


Second order differential equations are differential equations that have a second-derivative (yy'') in it.

Example: Solve the following Differential Equation:

d2ydx2=3x2\frac{d^2y}{dx^2} = 3x^2

Solution: The solution is to simply solve for yy by integrating to find dydx\frac{dy}{dx} first and then integrating again to find yy.

d2ydx2=3x2dxdydx=x3+C\int \frac{d^2y}{dx^2} = \int3x^2 dx \\ \rightarrow\\ \frac{dy}{dx}=x^3+C

Now, integrate again to solve for yy.

dy=(x3+C)dx y=x44+Cx+D\int dy = (x^3 + C )dx\ \\ \rightarrow\\ y=\frac{x^4}{4} + Cx + D

Since we already have a constant C, we have to add another constant D. We can now move on to solving constant-coefficient homogenous equations, to conclude the introduction to Second Order Differential Equations

Constant Coefficent Homogenous Equations

Constant Coefficent Homogenous Equations are of the type

ay+by+cy=0ay''+by'+cy=0

These are one of the easiest type of 2nd order ODEs to solve. The solution is of the form y=ekxy=e^{kx}.

The general solution can be found by taking the characteristic polynomial, like this:

ak2+bk+c=0ak^2+bk+c=0

Solve the above equation for mm​ and you get your solutions. The solutions come in 3 different forms, depending on the discriminant d=b24acd=b^2-4ac​​.

  1. d>0d > 0: C1em1x+C2em2xC_1e^{m_1x} + C_2e^{m_2x}
  2. d=0d=0: C1emx+C2xemxC_1e^{mx} + C_2xe^{mx}
  3. d<0d < 0: We get 2 complex roots, v±wiv \pm wi. evx(C1cos(wx)+C2sin(wx)i)e^{vx}(C_1cos(wx) + C_2sin(wx)i)

The solution of made up of 2 parts, ypy_p​ and yhy_h​. You get the general solution by combining both parts together: y=y1+y2y = y_1 + y_2​​.

For non-homogenous second order ODE’s, where the DE looks like this:

d2ydx2+pdxdy+qy=f(x)\frac{d^2y}{dx^2}+p\frac{dx}{dy}+qy=f(x)

The general solution is of the form y=yh+ypy=y_h + y_p.

yhy_h is the solution to the homogenous DE d2ydx2+pdxdy+qy=f(x)\frac{d^2y}{dx^2}+p\frac{dx}{dy}+qy=f(x)​​ and ypy_p is the particular solution. Finding ypy_p is more complicated, and there are multiple methods. Two of which are the method of undetermined coefficents and variation of parameters, both of which are discussed in later articles.

Example: Solve the following second order differential equation: y5y6y=0y''-5y'-6y=0.

Solution: This is a constant coefficent second order differential equation. Find the characteristic polynomial m25m6=0m^2-5m-6=0. Solve for mm to get m=2,3m=2,3. We have 2 real solutions, therefore our solution is y=C1e2x+C2e3xy=C_1e^{2x}+C_2e^{3x}. And that’s it, its as simple as that.

Python

Sympy Code: Solve the following Differential Equation y3y=9e3xy''- 3y' = -9e^{3x}

import numpy as np
from sympy import *
x, y = symbols('x y')
f = Function("f")
diffeq = Eq(f(x).diff(x, x) - 3*f(x).diff(x), -9*exp(3*x))
# y''- 3y' = -9e^{3x}
general_solution = dsolve(diffeq, f(x))
# f(x) = C1 + (C1 - 3x)e^{3x}

Sympy gives f(x)=C1+(C13x)e3xf(x) = C1 + (C1 - 3x)e^{3x} which you will see is correct as we solve this problem in the “Variation of parameters” section.

Created by Sharan Sajiv Menon, © 2022