Differential and Difference Equations

The Nature of Mathematical Modeling (draft)

$ \def\%#1{\mathbf{#1}} \def\*#1{\vec{#1}} \def\ds#1#2{\cfrac{d #1}{d #2}} \def\ps#1#2{\cfrac{\partial #1}{\partial #2}} \def\ba{\begin{eqnarray}} \def\ea{\end{eqnarray}} $

Ordinary Differential Equations

Order

  • Differential equations relate derivatives of functions. The order is the highest derivative that occurs.
  • A first-order equation can be immediately solved by integration:
$$ \ba \ds{y}{t} &=& f(t) \\ dy &=& f(t)~dt \\ y(t_1)-y(t_0) &=& \int_{t_0}^{t_1} f(t)~dt \ea $$

Ansatz

  • Differental equation solutions exist and are unique, so that if you find a solution it is the solution
  • Ansatz is a German word meaning approach or estimate
  • An ansatz can be used to solve a differental equation by guessing a form for the solution and then adjusting parameters; if it works then it is the solution

Linear Constant Coefficient

  • A linear constant coefficient differential equation is:
$$\frac{d^Ny}{dt^N}+A_1\frac{d^{N-1}y}{dt^{N-1}}+\cdots+A_{N-1}\ds{y}{y}+A_Ny = f(t)$$
  • These are frequently encountered, in part because they occur naturally, and in part because they are easy to solve

  • Try an ansatz $y = e^{kt}$ in the homogeneous problem $f(t)=0$:

$$e^{kt}\left(k^N+A_1k^{N-1}+\cdots+A_{N-1}k+A_N\right) = 0$$

That's solved by the characteristic equation:

$$k^N+A_1k^{N-1}+\cdots+A_{N-1}k+A_N = 0$$

This is an $N$th order polynomial that will have $N$ roots. The real part of the roots represent exponentially growing or decaying solutions, and the complex part oscillatory behavior. If the roots are distinct:

$$k^N+A_1k^{N-1}+\cdots+A_{N-1}k+A_N = (k-k_1)(k-k_2)\cdots (k-k_N)$$

then the general solution is:

$$y = \sum_{n=1}^N C_n e^{k_nt}$$

The $C_n$ are determined from the boundary conditions. In an initial value problem those are the value of the $y$ and its derivates; in a boundary value problem they've given at the beginning and end of an internval. If the roots are not distinct, the $M$ solutions for an $M$th order root are:

$$y = \left(C_1+C_2t+C_3t^2+\ldots C_Mt^{M-1}\right)e^{k_M}t$$

The complete solution is the sum of the general solution (from the homogeneous problem) and a particular solution to the inhomogeneous problem ($f(t) \ne 0$).

  • As an example, consider a simple RC circuit:
import matplotlib.pyplot as plt
import numpy as np
scale = .6
width = 7*scale
height = 3*scale
line = width/3
marker = 1.5*width
font = 3*width
fig,ax = plt.subplots(figsize=(width,height))
ax.axis([0,width,0,height])
ax.set_axis_off()
def resistor(x,y,width):
    x = scale*x
    y = scale*y
    width = scale*width
    dx = width/16
    dy = 2.5*dx
    xplot = np.linspace(x-width/2,x+width/2,17)
    yplot = y+np.array([0,0,0,dy,0,-dy,0,dy,0,-dy,0,dy,0,-dy,0,0,0])
    plt.plot(xplot,yplot,'k-',linewidth=line)
def capacitor(x,y,width):
    x = scale*x
    y = scale*y
    width = scale*width
    dy = width/2.5
    xplot = [[x-width,x-width,x,x],[x+width,x+width,x,x]]
    yplot = [[y+dy,y-dy,y+dy,y-dy],[y+dy,y-dy,y+width/2,y-width/2]]
    plt.plot(xplot,yplot,'k-',linewidth=line)    
def ground(x,y,width):
    x = scale*x
    y = scale*y
    width = scale*width
    xplot = [[x-.8*width,x-.55*width,x-.3*width,x],[x+.8*width,x+.55*width,x+.3*width,x]]
    yplot = [[y+.3*width,y,y-.3*width,y+.3*width],[y+.3*width,y,y-.3*width,y+.5*width]]
    plt.plot(xplot,yplot,'k-',linewidth=line)        
def wire(x0,y0,x1,y1):
    x0 = scale*x0
    x1 = scale*x1
    y0 = scale*y0
    y1 = scale*y1
    plt.plot([x0,x1],[y0,y1],'k-',linewidth=line)
def point(x,y):
    x = scale*x
    y = scale*y
    plt.plot(x,y,'ko',markersize=marker)
def circle(x,y):
    x = scale*x
    y = scale*y
    plt.plot(x,y,'ko',markersize=marker,markeredgewidth=width/2,
        markerfacecolor='white',markeredgecolor='black')
resistor(2,2.25,2)
wire(.75,2.25,1,2.25)
circle(.75,2.25)
wire(3,2.25,4,2.25)
circle(4,2.25)
point(3.25,2.25)
capacitor(3.25,1.25,.5)
wire(3.25,2.25,3.25,1.5)
ground(3.25,.25,.5)
wire(3.25,1,3.25,.5)
def text(x,y,text):
    x = scale*x
    y = scale*y
    ax.text(x,y,text,
        ha='center',va='center',
        math_fontfamily='cm',
        fontsize=font,color='black')
text(4,1.25,'$C$')
text(4.5,2.25,'$V_o$')
text(.3,2.25,'$V_i$')
text(2,1.6,'$R$')
plt.show()

The current through the resistor and capacitor must match:

$$C\dot{V}_o = \cfrac{V_i-V_o}{R}$$

therefore:

$$RC\dot{V}_o+V_o = V_i$$

The characteristic equation is:

$$ \ba RCr+1 &=& 0 \\ r &=& \cfrac{-1}{RC} \ea $$

therefore the undriven response is a decaying exponential:

$$V_o = Ae^{-t/RC}$$

To find the driven response, assume periodic forcing $V_i = \exp(i\omega t)$ (where ...). Trying an ansatz $V_o = A\exp(i\omega t)$ shows that:

$$ \ba RCi\omega+A &=& 1\\ A &=& \cfrac{1}{1+i\omega RC} \ea $$

At low frequencies the output is equal to the input; at high frequencies it rolls off as $1/\omega$ (it is a low-pass filter) and is out of phase by $90^\circ$. Problem 1 covers the important example of a damped, driven harmonic oscillator.

Systems of differential equations

Normal modes

diagonalization

Laplace Transforms

Perturbation Expansions

Partial Differential Equations

  • chain of oscillators
  • hyperbolic
  • parabolic
  • elliptic
  • SymPy

Origin

Types

Separation of Variables

Coordinate Systems

Difference Equations

  • ansatz

z-Transforms

Problems

  1. damped driven harmonic
  2. normal modes
  3. drum head
  4. generous children

(c) Neil Gershenfeld 1/9/26