01 An introduction to PDEs

What is a partial differential equation (PDE)?

What are equations? What do we do with them?

  • We use equations to describe relationships between quantities.

    • Often, some quantities are known, while others are unknown and need to be determined.

    • We need to “solve for” the unknown quantities in terms of the known ones.

Equations with numbers and algebraic operations

  • For example, in the equation \[ 2x + 3 = 9, \] we know the numbers \(2\), \(3\), and \(9\), the algebraic operations connecting them, and we want to solve for the unknown number \(x\).

  • The answer is easy: \(x = 3\).

Equations with functions and algebraic operations

  • For example, in the equation \[ 2f(x) + 4 = 10x^2, \] we know the numbers \(2\), \(4\), and the function \(10x^2\), the algebraic operations connecting them, and we want to solve for the unknown function \(f(x)\).

  • The answer is also easy: \(f(x) = 5x^2 - 2\).

Beyond “algebraic” equations

Equations with functions and differential operations

  • For example, in the equation \[ \frac{dy}{dx} = 2y, \] the function \(y(x)\) is unknown. It is embedded in an equation that involves an algebraic operation (multiplication by \(2\)) and a differential operation (taking the derivative with respect to \(x\)).

  • The answer is a bit less easy: \(y(x) = Ce^{2x}\), where \(C\) is an arbitrary constant determined by initial (or boundary) conditions.

  • Such equations are called differential equations because they involve differential operations.

  • This one happens to be an ordinary differential equation (ODE) because the unknown function \(y\) depends on a single variable \(x\).

    • A synonym for “ordinary” (in this context) is “single-variable.”
  • ODEs appear everywhere in the real world.

Example: Newton’s second law of motion

This equation says that \[ F = m \frac{d^2x}{dt^2}, \]

where \(x(t)\) is the position of an object as a function of time \(t\), \(m\) is its mass, and \(F\) is the force acting on it.

The central definition

Definition

A partial differential equation (PDE) is a differential equation that involves an unknown function of multiple variables and its partial derivatives.

  • A synonym for “partial” (in this context) is “multi-variable.”

The wave equation in 1 dimension

Example: the \(1\)-dimensional wave equation

This equation says that

\[ \frac{\partial^2 u}{\partial t^2} = a^2 \frac{\partial^2 u}{\partial x^2}, \]

where \(u(x,t)\) is a two-variable function and \(a\) is a known constant. It models wave-like phenomena, such as vibrations of a string, sound waves, electromagnetic waves, etc.

  • \(x\) typically represents a spatial variable (e.g., position along a string).
  • \(t\) typically represents time.
  • \(u(x,t)\) represents the displacement of the wave at position \(x\) and time \(t\).
import sys

sys.path.append("/Users/johnmyers/dev/site/teaching/aux-files")
import numpy as np
from plotting import plot_curve_animation, plot_surface

L = 10
blue = "#3399FF"


def u(x, t, n):
    return np.sin(n * np.pi * x / L) * np.cos(n * np.pi * t / L)


def u1(x, t):
    return u(x, t, 1)


x = np.linspace(0, L, 100)
t = np.linspace(0, 2 * L, 100)

plot_curve_animation(
    functions=[u1],
    colors=[blue],
    title="Harmonic n=1",
    x_vals=x,
    y_vals=[-2, 2],
    t_vals=t,
    x_axis_label="x = position",
    y_axis_label="u(x,t) = displacement",
)
X, T = np.meshgrid(x, t)

plot_surface(
    function=u1,
    X=X,
    Y=T,
    x_axis_label="x = position",
    y_axis_label="t = time",
    z_axis_label="u(x,t) = displacement",
    title="Harmonic n=1 over space and time",
)
def u2(x, t):
    return u(x, t, 2)


plot_curve_animation(
    [u2],
    labels=["Harmonic n=2"],
    colors=[blue],
    title="Harmonic n=2",
    x_vals=x,
    y_vals=[-2, 2],
    t_vals=t,
    x_axis_label="x = position",
    y_axis_label="u(x,t) = displacement",
)
plot_surface(
    function=u2,
    X=X,
    Y=T,
    x_axis_label="x = position",
    y_axis_label="t = time",
    z_axis_label="u(x,t) = displacement",
    title="Harmonic n=2 over space and time",
)
def u3(x, t):
    return u(x, t, 3)


plot_curve_animation(
    [u3],
    labels=["Harmonic n=3"],
    colors=[blue],
    title="Harmonic n=3",
    x_vals=x,
    y_vals=[-2, 2],
    t_vals=t,
    x_axis_label="x = position",
    y_axis_label="u(x,t) = displacement",
)
plot_surface(
    function=u3,
    X=X,
    Y=T,
    x_axis_label="x = position",
    y_axis_label="t = time",
    z_axis_label="u(x,t) = displacement",
    title="Harmonic n=3 over space and time",
)
def superposition(x, t):
    return u2(x, t) + u3(x, t)


plot_curve_animation(
    [u2, u3, superposition],
    labels=["n=2", "n=3", "superposition"],
    colors=[blue, "#FF3399", "#33FF99"],
    title="Superposition of harmonics n=2 and n=3",
    x_vals=x,
    y_vals=[-2, 2],
    t_vals=t,
    x_axis_label="x = position",
    y_axis_label="u(x,t) = displacement"
)
plot_surface(
    function=superposition,
    X=X,
    Y=T,
    x_axis_label="x = position",
    y_axis_label="t = time",
    z_axis_label="u(x,t) = displacement",
    title="Superposition of harmonics n=2 and n=3 over space and time",
)

The wave equation in 2 dimensions

Example: the \(2\)-dimensional wave equation

This equation says that

\[ \frac{\partial^2 u}{\partial t^2} = a^2 \left(\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2}\right), \]

where \(u(x,y,t)\) is a three-variable function and \(a\) is a known constant. It models wave-like phenomena in two spatial dimensions, such as waves on the surface of a pond.

  • \(x\) and \(y\) typically represent spatial variables (e.g., position on a surface).
  • \(t\) typically represents time.
  • \(u(x,y,t)\) represents the displacement of the wave at position \((x,y)\) and time \(t\).
import numpy as np
from plotting import plot_surface_animation


def u(x, y, t):
    return (
        np.sin(2 * np.pi * x) * np.sin(3 * np.pi * y) * np.sin(np.sqrt(13) * np.pi * t)
    )


def u0(x, y):
    return u(x, y, 0)


x = np.linspace(0, 1, 50)
y = np.linspace(0, 1, 50)
t_vals = np.linspace(0, 2, 200)
X, Y = np.meshgrid(x, y)

plot_surface_animation(
    function=u,
    init_function=u0,
    X=X,
    Y=Y,
    z_range=[-1, 1],
    t_vals=t_vals,
    x_axis_label="x = position",
    y_axis_label="y = position",
    z_axis_label="u(x,y,t) = displacement",
    title="Solution of 2D wave equation",
)