📈 TMA4135 - Mathematics 4D - Differential equations and Fourier analysis

Literature (PDFs)

Laplace Transforms

The Laplace transform F(s)F(s) of f(t)f(t) is given by

F(s)=L(f)=0estf(t)dtF(s) = \mathscr{L}(f) = \int_0^\infty e^{-st}f(t) dt

The inverse transform is denoted

f(t)=L1(F)f(t) = \mathscr{L}^{-1}(F)

The Laplace transform is a linear operation.

Solving an ODE with Laplace Transform

The process of solving an ODE using the Laplace transform method consists of three steps:

  1. The ODE is transformed into the subsidiary equation
  2. The subsidiary equation is solved by purely algebraic manipulations.
  3. The solution in Step 2 is transformed back, resulting in the solution of the given problem.

First Shifting Theorem, ss-Shifting

L{eatf(t)}=F(sa)\mathscr{L} \left\{ e^{at}f(t) \right\} = F(s-a)

Second Shifting Theorem, tt-Shifting

L{f(ta)u(ta)}=easF(s)\mathscr{L} \left\{ f(t-a)u(t-a) \right\} = e^{-as}F(s)

Existence and Uniqueness of Laplace Transforms

A function has a Laplace transform if it does not grow too fast, say, if for all t0t \geq 0 and some constants MM and kk it satisfies the growth restriction

f(t)Mekt|f(t)| \leq Me^{kt}

f(t)f(t) must also be piecewise continous.

Laplace Transform of the Derivative and Integral

L(f(n))=snF(s)sn1f(0)sn2f(0)f(n1)(0)\mathscr{L}(f^{(n)}) = s^n F(s) - s^{n-1}f(0) - s^{n-2}f'(0) - \dots - f^{(n-1)}(0)

L{0tf(τ)dτ}=1sF(s)\mathscr{L}\left\{ \int_0^t f(\tau) d\tau \right\} = \frac{1}{s} F(s)

Dirac’s Delta Function

δ(ta)={,if t=a0,otherwise\delta(t-a) = \begin{cases} \infty, & \text{if } t = a\\ 0, & \text{otherwise} \end{cases}

0δ(ta)dt=1\int_0^\infty \delta(t-a) dt = 1

The Sifting Property

0g(t)δ(ta)dt=g(a)\int_0^\infty g(t) \delta(t-a) dt = g(a)

The Laplace Transform and Convolution

If f(t)f(t) and g(t)g(t) are defined only on t>0t>0

(fg)(t)=0tf(τ)g(tτ)dτ(f \ast g)(t) = \int_0^t f(\tau)g(t-\tau) d\tau

L{fg}=L(f)L(g)\mathscr{L} \left\{ f \ast g \right\} = \mathscr{L}(f) \cdot \mathscr{L}(g)

0tf(τ)dτ=1f(t)\int_0^t f(\tau) d\tau = 1 \ast f(t)

Convolution is commutative, distributive and associative.

Fourier Analysis

Fourier Series

Periodic Functions

A function f(x)f(x) is called periodic if there is some positive number pp, called a period of f(x)f(x), such that

f(x+p)=f(x)f(x + p) = f(x)

The Fourier Series and Coefficients

f(x)=a0+n=1(ancos(nπLx)+bnsin(nπLx))f(x) = a_0 + \sum_{n=1}^{\infty} \left(a_n \cos\left(\frac{n\pi}{L}x\right) + b_n \sin\left(\frac{n\pi}{L}x\right)\right)

For a periodic function f(x)f(x) with period p=2Lp = 2L we have the Euler formulas

a0=12LLLf(x)dxan=1LLLf(x)cos(nπLx)dxbn=1LLLf(x)sin(nπLx)dx\begin{aligned} a_0 &= \frac{1}{2L} \int_{-L}^L f(x) dx \\ a_n &= \frac{1}{L} \int_{-L}^L f(x) \cos\left(\frac{n\pi}{L}x\right) dx \\ b_n &= \frac{1}{L} \int_{-L}^L f(x) \sin\left(\frac{n\pi}{L}x\right) dx \\ \end{aligned}

Even and Odd Functions

If f(x)f(x) is an even function, that is, f(x)=f(x)f(-x) = f(x), then bn=0b_n = 0, reducing its Fourier series to a Fourier cosine series with

a0=1L0Lf(x)dxan=2L0Lf(x)cos(nπLx)dx\begin{aligned} a_0 &= \frac{1}{L} \int_0^L f(x) dx \\ a_n &= \frac{2}{L} \int_0^L f(x) \cos\left(\frac{n\pi}{L}x\right) dx \\ \end{aligned}

If f(x)f(x) is an odd function, that is, f(x)=f(x)f(-x) = -f(x), then an=0a_n = 0, reducing its Fourier serier to a Fourier sine series with

bn=2L0Lf(x)sin(nπLx)dx\begin{aligned} b_n &= \frac{2}{L} \int_0^L f(x) \sin\left(\frac{n\pi}{L}x\right) dx \\ \end{aligned}

The Complex Fourier Series

f(x)=n=cneinπLxf(x) = \sum_{n=-\infty}^\infty c_n e^{\frac{in\pi}{L} x}

where

cn=12LLLf(x)einπLxdxc_n = \frac{1}{2L} \int_{-L}^L f(x) e^{-\frac{in\pi}{L} x} dx

For even functions ff, the complex Fourier coefficients are real. For odd functions ff, the complex Fourier coefficients are purely imaginary.

Euler's formula

The above is derived from the Euler's formula:

eix=cos(x)+isin(x)e^{ix} = \cos(x) + i \sin(x)

Half-Range Expansions

Approximation by Trigonometric Polynomials

The Nth partial sum of the Fourier series is an approximation of the given f(x)f(x). The square error of the Nth partial sum is minimal only if the coefficients are the Fourier coefficients of ff.

f(x)a0+n=1N(ancos(nπLx)+bnsin(nπLx))f(x) \approx a_0 + \sum_{n=1}^{N} \left(a_n \cos\left(\frac{n\pi}{L}x\right) + b_n \sin\left(\frac{n\pi}{L}x\right)\right)

Parseval’s Identity

2a02+n=1(an2+b22)=1πππf(x)2dx2a_0^2 + \sum_{n=1}^\infty (a_n^2 + b_2^2) = \frac{1}{\pi} \int_{-\pi}^\pi f(x)^2 dx

The error of the Nth partial sum is equal to the difference of the left and right parts of Parseval's identity.

Fourier Integral

f(x)=0[A(w)cos(wx)+B(w)sin(wx)]dwf(x) = \int_0^\infty \left[ A(w) \cos(wx) + B(w) \sin(wx) \right] dw

where

A(w)=1πf(v)cos(wv)dvB(w)=1πf(v)sin(wv)dv\begin{aligned} A(w) &= \frac{1}{\pi} \int_{-\infty}^\infty f(v) \cos(wv) dv \\ B(w) &= \frac{1}{\pi} \int_{-\infty}^\infty f(v) \sin(wv) dv \\ \end{aligned}

Fourier Transform

Fourier Transform and Its Inverse

The Fourier transform of ff is given by

f^(w)=F(f)=12πf(x)eiwxdx\hat{f}(w) = \mathscr{F}(f) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^\infty f(x)e^{-iwx} dx

and the inverse Fourier transform is given by

f(x)=F1(f^)=12πf^(w)eiwxdwf(x) = \mathscr{F}^{-1}(\hat{f}) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^\infty \hat{f}(w)e^{iwx} dw

Like the Laplace transform, the Fourier transform is a linear operation.

Fourier Transform of the Derivative and Integral

F{f(x)}=iwF{f(x)}\mathscr{F} \left\{ f'(x) \right\} = iw \mathscr{F} \left\{ f(x) \right\}

f^(w)=F{ixf(x)}\hat{f}'(w) = \mathscr{F} \left\{ -ixf(x) \right\}

The Fourier Transform and Convolution

F(fg)=2πF(f)F(g)\mathscr{F}(f \ast g) = \sqrt{2\pi} \mathscr{F}(f) \mathscr{F}(g)

(fg)(x)=f^(w)g^(w)eiwxdw(f \ast g)(x) = \int_{-\infty}^{\infty} \hat{f}(w)\hat{g}(w)e^{iwx} dw

Discrete Fourier Transform (DFT)

The discrete Fourier transform (DFT) f^\bold{\hat{f}} of a signal f\bold{f} is given by

f^n=k=0N1fkei2πnkN\bold{\hat{f}}_n = \sum_{k=0}^{N-1} \bold{f}_k e^{-i\frac{2\pi nk}{N}}

Alternatively, as a matrix-vector product:

f^=FNf\bold{\hat{f}} = \bold{F}_N \bold{f}

where f\bold{f} are sample values of f(x)f(x),

w=wN=e2πi/Nw = w_N = e^{-2\pi i/N}

and

FN=[w0w0w0w0w0w1w2wN1w0w2w4w2(N1)w0wN1w2(N1)w(N1)2]\bold{F}_N = \begin{bmatrix} w^0 & w^0 & w^0 & \dots & w^0 \\ w^0 & w^1 & w^2 & \dots & w^{N-1} \\ w^0 & w^2 & w^4 & \dots & w^{2(N-1)} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ w^0 & w^{N-1} & w^{2(N-1)} & \dots & w^{(N-1)^2} \\ \end{bmatrix}

The inverse transform is given by

f=FN1f^=1NFNf^\bold{f} = \bold{F}_N^{-1} \bold{\hat{f}} = \frac{1}{N}\overline{\bold{F}}_N \bold{\hat{f}}

DFT of Cosine and Sine

fk=cos(2πknN)    f^=(00,,0n1,N2,0,,0,N2,0Nn+1,,0N1)f_k = \cos\left( \frac{2\pi kn}{N} \right) \implies \hat{\bold{f}} = \left( 0_0, \dots, 0_{n-1}, \frac{N}{2}, 0, \dots, 0, \frac{N}{2}, 0_{N-n+1}, \dots, 0_{N-1}\right)

gk=sin(2πknN)    g^=(00,,0n1,iN2,0,,0,+iN2,0Nn+1,,0N1)g_k = \sin\left( \frac{2\pi kn}{N} \right) \implies \hat{\bold{g}} = \left( 0_0, \dots, 0_{n-1}, -i\frac{N}{2}, 0, \dots, 0, +i\frac{N}{2}, 0_{N-n+1}, \dots, 0_{N-1}\right)

Partial Differential Equations (PDEs)

A PDE is an equation that contains one or more partial derivatives of an unknown function that depends on at least two variables.

ODE and PDE terminology

Term Definition
Order The order of the highest derivative
Degree The highest exponent of the unknown function (uu)
Linear Of first degree, otherwise nonlinear
Homogeneous If u=0u = 0 is a valid solution, else nonhomogeneous
Boundary conditions Conditions of the space boundary, e.g. u(0,t)u(0, t)
Initial conditions Conditions of the time boundary, e.g. u(x,0)u(x, 0)
Dimensions The number of space variables (x, y, z, etc.)

Basic Concepts of PDEs

Solution by Separating Variables. Use of Fourier Series

// TODO: Combine separation of variables explanation from wave and heat equations (difficult)

d'Alembert

A quick solution of the wave equation with initial conditions u(x,0)=f(x)u(x, 0) = f(x) and ut(x,0)=g(x)u_t(x, 0) = g(x).

u(x,t)=12[f(x+ct)+f(xct)]+12cxctx+ctg(s)dsu(x, t) = \frac{1}{2} \left[f(x+ct) + f(x-ct)\right] + \frac{1}{2c} \int_{x-ct}^{x+ct} g(s) ds

Otherwise, we consider the following general solution with speed cc and manipulate to match the initial and boundary conditions

u(x,t)=ϕ(x+ct)+ψ(xct)u(x, t) = \phi(x + ct) + \psi(x - ct)

Heat Equation: Modeling Very Long Bars. Solution by Fourier Integrals and Transforms

// TODO: Use of Fourier Transforms (difficult) // Solve PDE by Fourier transform

Rounding errors in numerical differentiation (4N)

Partial derivatives (4D)

Chain rule

For a scalar function h(x)=f(g(x))h(x) = f(g(x))

hx=fx(g(x))gx(x)\frac{\partial h}{\partial x} = \frac{\partial f}{\partial x}(g(x)) \cdot \frac{\partial g}{\partial x}(x)

For a vector function g(t)=f(x(t))g(t) = f(\overrightarrow{x}(t))

gt=f(x(t))xt\frac{\partial g}{\partial t} = \overrightarrow{\nabla} f(\overrightarrow{x}(t)) \cdot \frac{\partial \overrightarrow{x}}{\partial t}

where \cdot is the dot product.

Gradient

The gradient of f=f(x1,x2,,xn)f = f(x_1, x_2, \dots, x_n) is given by

f=(fx1,fx2,,fxn)\overrightarrow{\nabla} f = \left( \frac{\partial f}{\partial x_1}, \frac{\partial f}{\partial x_2}, \dots, \frac{\partial f}{\partial x_n} \right)

Directional derivative

The directional derivate of ff, in the direction u\overrightarrow{u}, is given by

Duf(a)=f(a)uD_{\overrightarrow{u}} f(\overrightarrow{a}) = \overrightarrow{\nabla} f(\overrightarrow{a}) \cdot \overrightarrow{u}

Jacobi matrix (Jacobian)

The Jacobian of f=(f1(x1,,xn),,fn(x1,,xn))f = (f_1(x_1, \dots, x_n), \dots, f_n(x_1, \dots, x_n)) is a matrix where each element is given by

Jij(x)=fixjJ_{ij}(x) = \frac{\partial f_i}{\partial x_j}

For example, if f=(f(x,y),g(x,y))f = (f(x, y), g(x, y))

J(x)=[fxfygxgy]J(\overrightarrow{x}) = \begin{bmatrix} \frac{\partial f}{\partial x} & \frac{\partial f}{\partial y} \\ \frac{\partial g}{\partial x} & \frac{\partial g}{\partial y} \\ \end{bmatrix}

Hess matrix (Hessian)

The Hessian of ff, HfH_f is the Jacobian of the gradient of ff.

Partial Derivatives and Taylor Series

f(a+h)=f(a)+f(a)h+hTHf(a)h+f(\overrightarrow{a} + \overrightarrow{h}) = f(\overrightarrow{a}) + \overrightarrow{\nabla} f(\overrightarrow{a}) \cdot \overrightarrow{h} + \overrightarrow{h}^T \cdot H_f(\overrightarrow{a}) \cdot \overrightarrow{h} + \dots

Preliminaries

Terminology

Term Definition
Cm[a,b]C^m[a,b] The set of all functions with continuous first mm derivatives on the interval [a,b][a, b].
Pn\mathbb{P}_n The set of all polynomials of degreeat most nn.
f|f|_\infty maxxf(x)\max_{x \in } \lvert f(x)\rvert
f2|f|_2 abf(x)2dx\sqrt{\int_a^b f(x)^2 dx}
x|\bold{x}|_\infty maxi=1mxi\max_{i=1}^m \lvert x_i\rvert
x2|\bold{x}|_2 i=1mxi2\sqrt{\sum_{i=1}^m x_i^2}

Order of convergence

The order of convergence is pp if there exists a positive constant MM such that

ek+1Mekpe_{k+1} \leq Me_k^p

where eke_k is the error of the kk-th iteration.

The order can be numerically verified with the following approximation

plog(ek+2/ek+1)log(ek+1/ek)p \approx \frac{\log(e_{k+2} / e_{k+1})}{\log(e_{k+1} / e_{k})}

hh-dependent approximations

e(h)=XX(h)e(h) = ||X-X(h)||. The order of the approximation is pp if there exists a positive constant MM such that that

e(h)Mhpe(h) \leq Mh^p

alternatively, with Big OO-notation

e(h)=O(hp)e(h) = O(h^p)

The order of hh-dependent approximations can be numerically verified with the following approximation, where hk+1h_{k+1} is some step size smaller then hkh_k.

plog(e(hk+1)/e(hk))log(hk+1/hk)p \approx \frac{\log(e(h_{k+1}) / e(h_k))}{\log(h_{k+1} / h_{k})}

Taylor Expansions

Given a function fC[a,b]f \in C^\infty[a, b], the Taylor polynomial of degree mm of ff around aa is then given by

f(x)=k=0m(xa)kk!f(k)(a)+Rm+1(x)f(x) = \sum_{k=0}^m \frac{(x - a)^k}{k!} f^{(k)}(a) + R_{m+1}(x)

Choose a point xx and an increment hh such that x,x+h[a,b]x, x + h \in [a, b]. The Taylor polynomial of degree mm of ff around xx is then given by

f(x+h)=k=0mhkk!f(k)(x)+Rm+1(x)f(x + h) = \sum_{k=0}^m \frac{h^k}{k!} f^{(k)}(x) + R_{m+1}(x)

where

Rm+1(x)=hm+1(m+1)!f(m+1)(ξ)=O(hm+1)R_{m+1}(x) = \frac{h^{m+1}}{(m+1)!} f^{(m+1)}(\xi) = O(h^{m+1})

Intermediate Value Theorem

Let fC[a,b]f \in C[a, b] and let xx be some number between f(a)f(a) and f(b)f(b), then there exist at least one ξ(a,b)\xi \in (a, b) such that f(ξ)=xf(\xi) = x.

Mean Value Theorem

Let fC1[a,b]f \in C^1[a, b]. Then there exists at least one ξ(a,b)\xi \in (a, b) such that

f(ξ)=f(b)f(a)baf'(\xi) = \frac{f(b) - f(a)}{b - a}

Mean Value Theorem for Integrals

Let fC[a,b]f \in C[a, b] and gg an integrable function that does not change sign on [a,b][a, b]. Then there exists at least one ξ(a,b)\xi \in (a, b) such that

abf(x)g(x)dx=f(ξ)abg(x)dx\int_a^b f(x)g(x)dx = f(\xi) \int_a^b g(x) dx

Numerical Differentiation and Numerical Solution of Boundary Value Problems

Constructing a finite difference scheme for solving a linear BVP is composed from the following steps:

  1. Discretize the domain on which the equation is defined.
  2. On each grid point, replace the derivatives with an approximation, using the values in neighbouring grid points.
  3. Replace the exact solutions by its approximations.
  4. Solve the resulting system of equations with boundary and or intial conditions.

Numerical differentiation

f(x)={f(x+h)f(x)hh2f(ξ),Forward differencef(x)f(xh)h+h2f(ξ),Backward differencef(x+h)f(xh)2hh26f(ξ),Central differencef'(x) = \begin{cases} \frac{f(x+h)-f(x)}{h} - \frac{h}{2}f''(\xi), & \text{Forward difference} \\ \frac{f(x)-f(x-h)}{h} + \frac{h}{2}f''(\xi), & \text{Backward difference} \\ \frac{f(x+h)-f(x-h)}{2h} - \frac{h^2}{6}f'''(\xi), & \text{Central difference} \\ \end{cases}

f(x)=f(x+h)2f(x)+f(xh)h2h212f(4)(ξ)Central differencef''(x) = \frac{f(x+h)-2f(x)+f(x-h)}{h^2} - \frac{h^2}{12}f^{(4)}(\xi) \quad \text{Central difference}

When approximating, we use only the first terms. The second terms then become the error. The errors may also be written as O(h)O(h) for forward and backward difference and O(h2)O(h^2) for central difference for the first and second derivative.

Interpolation

With the direct polynomial approach to solving an interpolation problem where n+1n+1 points (xi,yi)(x_i, y_i) are given, we let p(x)=cnxn+cn1xn1++c1x1+c0p(x) = c_nx^n + c_{n-1}x^{n-1} + \dots + c_1x_1 + c_0 and create a linear system of n+1n + 1 equations p(xi)=yip(x_i) = y_i, which we solve for all cic_i.

With spline interpolation, we use piecewise polynomials. Linear splines results in straight lines between each point. Cubic splines are the most important in practise.

Numerical integration

A numerical quadrature or a quadrature rule is a formula, usually of the form of the left, for approximating integrals such as the one on the right. We call wiw_i weights and xix_i nodes.

Q[f](a,b)=i=0nwif(xi)I[f](a,b)=abf(x)dxQ[f](a, b) = \sum_{i=0}^n w_i f(x_i) \approx I[f](a, b) = \int_a^b f(x) dx

In practice, we will not use a single (or simple) quadrature for the whole interval [a,b][a, b], but rather apply a quadrature on each of mm subintervals [Xj,Xj+1],j=0,1,,m1[X_j , X_{j+1}], j = 0, 1, \dots, m-1, and then add the results together. This leads to composite quadratures yielding the approximation

I[f](a,b)j=0m1Q[f](Xj,Xj+1)I[f](a, b) \approx \sum_{j=0}^{m-1} Q[f] (X_j, X_{j+1})

It is common to define a quadrature from nodes on the standard interval [1,1][-1, 1], and then transferring it to an arbitrary interval [a,b][a, b]. This transformation is done by

x=ba2t+b+a2,dx=ba2dtx = \frac{b-a}{2}t + \frac{b+a}{2}, \qquad dx = \frac{b-a}{2}dt

See the Simpson's rule below for an example.

Quadrature Rule Examples

Simpson's Rule

S(1,1)=13[f(1)+4f(0)+f(1)]S(-1, 1) = \frac{1}{3}\left[ f(-1) + 4f(0) + f(1) \right]

S(a,b)=ba6[f(a)+4f(a+b2)+f(b)]S(a, b) = \frac{b-a}{6}\left[ f(a) + 4f\left(\frac{a+b}{2}\right) + f(b)\right]

Sm(a,b)=h3[f(x0)+4j=0m1f(x2j+1)+2j=1m1f(x2j)+f(x2m)]S_m(a, b) = \frac{h}{3} \left[ f(x_0) + 4\sum_{j=0}^{m-1} f(x_{2j+1}) + 2\sum_{j=1}^{m-1}f(x_{2j}) + f(x_{2m}) \right]

ES(a,b)=I[f](a,b)S(a,b)=(ba)52880f(4)(ξ)E_{S}(a, b) = I[f](a, b) - S(a, b) = - \frac{(b-a)^5}{2880} f^{(4)}(\xi)

ESm(a,b)=I[f](a,b)Sm(a,b)=(ba)h4180f(4)(ξ)E_{S_m}(a, b) = I[f](a, b) - S_m(a, b) = - \frac{(b-a)h^4}{180} f^{(4)}(\xi)

Trapezoidal rule

T(a,b)=ba2(f(a)+f(b))T(a, b) = \frac{b-a}{2}(f(a) + f(b))

Tm(a,b)=h[12f(x0)+j=1m1f(xj)+12f(xm)]T_m(a, b) = h \left[ \frac{1}{2} f(x_0) + \sum_{j=1}^{m-1} f(x_j) + \frac{1}{2} f(x_m) \right]

ET(a,b)=I[f](a,b)T(a,b)=(ba)312f(ξ)E_{T}(a, b) = I[f](a, b) - T(a, b) = - \frac{(b-a)^3}{12} f''(\xi)

ETm(a,b)=I[f](a,b)Tm(a,b)=(ba)h212f(ξ)E_{T_m}(a, b) = I[f](a, b) - T_m(a, b) = - \frac{(b-a)h^2}{12} f''(\xi)

The Midpoint Rule

M(a,b)=(ba)f(a+b2)M(a, b) = (b-a) f \left( \frac{a + b}{2} \right)

Mm(a,b)=bamj=0m1f(xj+1/2)M_m(a, b) = \frac{b-a}{m} \sum_{j=0}^{m-1} f(x_{j+1/2})

EM(a,b)=I[f](a,b)M(a,b)=(ba)324f(ξ)E_{M}(a, b) = I[f](a, b) - M(a, b) = - \frac{(b-a)^3}{24} f''(\xi)

EMm(a,b)=I[f](a,b)Mm(a,b)=(ba)h224f(ξ)E_{M_m}(a, b) = I[f](a, b) - M_m(a, b) = - \frac{(b-a)h^2}{24} f''(\xi)

Gauss-Legendre Quadrature

For the standard interval [1,1][−1, 1] choose the nodes as the zeros of the polynomial of degree nn:

Ln(t)=dndtn(t21)nL_n(t) = \frac{d^n}{dt^n} (t^2-1)^n

The resulting quadrature rules have a degree of precision d=2n1d = 2n − 1, and the corresponding composite rules have a convergence order of 2n2n.

Error Estimation for Quadratures

We can create an upper bound for the error by maximizing the f(n)(ξ)f^{(n)}(\xi) term. This bound, however, often vastly overestimates the actual error.

A better error estimation may be found by:

Adaptive Integration

An adaptive quadrature is a recursive algorithm which for each step accepts the result Q(a,b)+E(a,b)Q(a,b) + \Epsilon(a,b) if E(a,b)Tol|\Epsilon(a, b)| \leq \text{Tol}, otherwise it splits the interval in two halves and calls the procedure on these subintervals with tolerance Tol/2\text{Tol}/2.

Numerical Solution of Nonlinear Equations

Existence and uniqueness of a solution

The intermediate value theorem is used to prove the existence of a solution, and monotonicity (f(x)>0|f'(x)| > 0) proves that the solution is unique.

Fixed Point Iterations

Given gg such that r=g(r)r = g(r), and a starting value x0x_0

xk+1=g(xk),k=0,1,2,x_{k+1} = g(x_k), \qquad k = 0, 1, 2, \dots

If gg is continous and a<g(x)<ba < g(x) < b on [a,b][a, b] and there exist a positive constant LL such that g(x)L<1|g'(x)| \leq L < 1 for all x[a,b]x \in [a, b] then

Newton's Method

Given f(x)=0f(x) = 0 and a starting value x0x_0, Newton's method is given by

xk+1=xkf(xk)f(xk),k=0,1,2,x_{k+1} = x_k - \frac{f(x_k)}{f'(x_k)}, \qquad k = 0, 1, 2, \dots

Assume that ff has a root rr, and is two times continuously differentiable on Iδ=[rδ,r+δ]I_\delta = [r - \delta, r + \delta] for some δ>0\delta > 0. If there is a positive constant MM such that

f(x1)f(x2)2M, for all x1,x2,Iδ\left| \frac{f''(x_1)}{f'(x_2)} \right| \leq 2M, \qquad \text{ for all } x_1, x_2, \in I_\delta

then Newton's iterations converge quadratically,

ek+1Mek2|e_{k+1}| \leq M|e_k|^2

for all starting values x0x_0 satisfying x0rmin{1/M,δ}|x_0 - r| \leq \min\{1/M, \delta\}.

Newton's Method for Systems of Equations

Given a vector function f(x):RmRm\bold{f(x)}: \mathbb{R}^m \rightarrow \mathbb{R}^m, its Jacobian J(x)J(\bold{x}) and a starting value x0\bold{x}_0. For k=0,1,2,k = 0, 1, 2, \dots

Alternatively, with the inverse Jacobian J(x)1J(\bold{x})^{-1}

Numerical Solution of Partial Differential Equations

Explicit Scheme

For an explicit scheme, we follow the same procedure as in Numerical Solutions of BVP, but use the notation Uinu(xi,tn)U_i^n \approx u(x_i, t_n) since we now have two variables.

For values outside of the domain (e.g. UiiU_{i}^{-i} or Uin+1U_{i}^{n+1}), we once again use an approximation (e.g. central difference) to represent the value from values within the domain.

The Explicit Euler method uses central differences in the xx-direction, and forward differences in the tt-direction.

Wave Equation

The Courant–Friedrichs–Lewy (CFL) stability condition states that our numerical method is stable for the wave equation if and only if

ckh1c\frac{k}{h} \leq 1

Heat Equation

Boundary conditions Form, for (t>0)(t > 0)
Dirichlet u(0,t)=g0(t),u(L,t)=gL(t)u(0,t) = g_0(t), \quad u(L, t) = g_L(t)
Neumann xu(0,t)=g0(t),xu(L,t)=gL(t)\partial_x u(0,t) = g_0(t), \quad \partial_x u(L,t) = g_L(t)
Robin (or mixed) a0xu(0,t)+b0u(0,t)=g0(t),aLxu(0,t)+bLu(0,t)=gL(t)a_0 \partial_x u(0,t) + b_0 u(0,t) = g_0(t), \quad a_L \partial_x u(0,t) + b_L u(0,t) = g_L(t)

Our numerical method is once again stable for the heat equation if and only if

c2hk212c^2 \frac{h}{k^2} \leq \frac{1}{2}

Implicit Scheme (Implicit Euler)

By swapping the forward differences in tt-direction of the explicit Euler method with backward differences, we get the implicit Euler method. The result is a system of linear equations. The implicit Euler method for the heat equation is unconditionally stable.

Crank-Nicolsen method

The idea of the Crank-Nicolson method is to combine the updates for the explicit and the implicit Euler methods.

// TODO: Crank-Nicolsen method

Numerical Solution of Ordinary Differential Equations

Scalar ODE

A scalar ODE is an equation of the form

y(t)=f(t,y(t)),y(t0)=y0y'(t) = f(t, y(t)), \qquad y(t_0) = y_0

The initial condition is required for a unique solution, and makes it an initial value problem (IVP).

For example,

y=2tyy' = -2ty

has the solution

y(t)=Cet2y(t) = Ce^{-t^2}

where C depends on the initial condition y(t0)y(t_0).

System of ODEs

A system of ODEs (in vector form) is given by

y(t)=f(t,y(t)),y(t0)=y0\bold{y}'(t) = \bold{f}(t, \bold{y}(t)), \qquad \bold{y}(t_0) = \bold{y}_0

Higher order ODEs

An ODEs of order mm

y(m)=f(t,y,y,,y(m1)),y(t0)=y0,y^{(m)} = f(t, y, y', \dots, y^{(m-1)}), \quad y(t_0) = y_0, \dots

may be written as a system of first order ODEs like the following

z=[yyy(m1)],z=[yyf(t,y,y,,y(m1))],z0=[y0y0y0(m1)]\bold{z} = \begin{bmatrix} y \\ y' \\ \vdots \\ y^{(m-1)} \end{bmatrix}, \qquad \bold{z'} = \begin{bmatrix} y' \\ y'' \\ \vdots \\ f(t, y, y', \dots, y^{(m-1)}) \end{bmatrix}, \qquad \bold{z}_0 = \begin{bmatrix} y_0 \\ y'_0 \\ \vdots \\ y_0^{(m-1)} \end{bmatrix}

Euler's method

yn+1=yn+hf(tn,yn)\bold{y}_{n+1} = \bold{y}_n + h\bold{f}(t_n, \bold{y}_n)

Heun's method

k1=f(tn,yn),k2=f(tn+h,yn+hk1),yn+1=yn+h2(k1+k2),\begin{aligned} \bold{k}_1 &= \bold{f}(t_n, \bold{y}_n), \\ \bold{k}_2 &= \bold{f}(t_n + h, \bold{y}_n + h\bold{k}_1), \\ \bold{y}_{n+1} &= \bold{y}_n + \frac{h}{2}(\bold{k}_1 + \bold{k}_2), \\ \end{aligned}

Runge–Kutta methods

An ss-stage Runge-Kutta method is given by

ki=f(tn+cih,yn+hj=1saijkj),i=1,2,,s,yn+1=yn+hi=1sbiki\begin{aligned} \bold{k}_i &= \bold{f}(t_n + c_ih, \bold{y}_n + h \sum_{j=1}^s a_{ij}\bold{k_j}), \qquad i = 1,2,\dots,s, \\ \bold{y}_{n+1} &= \bold{y}_n + h\sum_{i=1}^s b_i \bold{k}_i \end{aligned}

The method is defined by its coefficients aij,bi,cia_{ij}, b_i, c_i, which may be visualized in a Butcer tableau. The method is explicit if aij=0a_{ij} = 0 whenever iji \geq j; otherwise it is implicit.

Lipschitz Continuity

A function ff is lipschitz continous if there exists a constant LL such that

f(t,y1)f(t,y2)Ly1y2for all t,y1,y2 in the domain\| f(t, y_1) - f(t, y_2) \| \leq L \| y_1 - y_2 \| \qquad \text{for all $t, y_1, y_2$ in the domain}

Consider the IVP y=f(t,y),y(t0)=y0\bold{y}' = \bold{f}(t, \bold{y}), \quad \bold{y}(t_0) = \bold{y}_0. If f(t,y)f(t, y) is lipschitz continous in DD, then the ODE has one and only one solution in DD.

Order of a method

A method is of order p>0p > 0 if there is a constant C>0C > 0 such that

eN=y(tend)yNChp,whereh=(tendt0)/N\| \bold{e}_N \| = \|\bold{y}(t_{end}) - \bold{y}_N \| \leq Ch^p, \qquad \text{where} h = (t_{end} - t_0)/N

Order conditions for Runge–Kutta methods

See the formula sheet

Error Estimation for Numerical Solutions of ODEs

A reasonable approximation to the unknown local error ln+1\bold{l}_{n+1} is the local error estimate len+1\bold{le}_{n+1}

len+1=y^n+1yn+1ln+1\bold{le}_{n+1} = \hat{\bold{y}}_{n+1} - \bold{y}_{n+1} \approx \bold{l}_{n+1}

where yn+1\bold{y}_{n+1} is found by a method of order pp and y^n+1\hat{\bold{y}}_{n+1} is found by a method of order p+1p+1.

Stepsize control

After a step nn, the next step size is given by

hnew=P(Tollen+1)1p+1hnh_{new} = P \left( \frac{\text{Tol}}{\| \bold{le}_{n+1} \|} \right)^{\frac{1}{p + 1}} h_n

where the pessimist factor P<1P < 1 is some chosen constant, normally between 0.50.5 and 0.950.95. We only move forwards if len+1<Tol|\bold{le}_{n+1} < \text{Tol}.

Runge–Kutta Methods with an Error Estimate

The error estimate is then given by

len+1=hi=1s(b^ibi)ki\bold{le}_{n+1} = h\sum_{i=1}^s (\hat{b}_i - b_i)\bold{k}_i

Linear stability analysis

Linear stability can be analyzed by studying the very simple linear test equation

y=λy,y(0)=y0y' = \lambda y, \qquad y(0) = y_0

One step of some Runge–Kutta method applied to the linear test equation can always be written as

yn+1=R(z)yn,z=λhy_{n+1} = R(z)y_n, \qquad z = \lambda h

where R(z)R(z) is called the stability function of the method.

The stability region of a method is defined by

S={zC:R(z)1}S = \{ z \in \mathbb{C} : |R(z)| \leq 1 \}

To get a stable numerical solution, we have to choose the step size hh such that z=λhSz = \lambda h \in S.

AA-stable methods

A method is AA-stable if the stability region SS covers C\mathbb{C}^-. This means that it is stable for all λC\lambda \in \mathbb{C}^- independent of hh. Explicit methods can never be AA-stable.