IV. Differential equations and advanced analysis

38. Partial differential equations

Type the equation with subscripts u_t, u_xx, u_xy (from a photo the app also reads ∂u/∂t and ∂²u/∂x²), the Laplacian as Δu; the conditions and the domain a semicolon apart. Without conditions the app finds a linear second-order equation’s type (elliptic, parabolic, hyperbolic – by region for variable coefficients), the characteristic equation, the canonical form and, without lower-order terms, the general solution. A first-order equation a·u_x + b·u_y + c·u = f is solved by characteristics with a check.

With boundary and initial conditions it solves by separation of variables the heat equation u_t = k·u_xx and the wave equation u_tt = c²·u_xx on an interval (ends held at a temperature or insulated, nonzero values via the steady state) and Laplace’s equation on a rectangle and in a disk (or outside it). The Fourier coefficients come as a formula in n; an initial function that is a sum of eigenfunctions gives a finite sum. On the whole line it uses d’Alembert’s formula and the Fourier transform (the heat kernel), on a half-line x > 0 the Laplace transform in time. It also handles a source f(x, t) (Duhamel’s principle), a heat flux at an end, boundary values changing in time and, for Laplace’s equation, derivatives on the sides. Of the nonlinear equations it solves Burgers’ – by characteristics until a shock forms, with viscosity by the Cole-Hopf transformation; the wave equation on the line is also shown by the Fourier transform. Poisson’s equation Δu = f on a rectangle is solved by a double Fourier series (the source as a sum of products p(x)·q(y)); with all four sides given by the derivative the solvability condition is checked and the solution comes up to a constant. Equations with the variable coefficients αx²u_xx + βxu_x turn into a Sturm–Liouville problem with a weight.

Numerically on a grid with the scheme as the head, as with the other numerical methods: the heat equation explicitly (ftcs), implicitly (btcs), by Crank-Nicolson (cranknicolson) and the θ-method (theta) – the implicit systems by the Thomas algorithm, with von Neumann’s stability analysis; the transport equation by upwind, laxwendroff and leapfrog with the CFL condition, the wave equation by leapfrog; Laplace’s (Poisson’s) equation by the five-point scheme and the iterations jacobi, gaussseidel and sor with their iteration counts compared. Named values: h the space step, k the time step, to the final time, theta, omega, tol, max. The heat equation is also a form in Numerical methods. Heat in 2D on a rectangle is solved by the schemes ftcs and adi (alternating directions), Laplace’s equation also by conjugate gradients (cg), multigrid (multigrid) and finite elements with triangles (fem); Burgers’ equation by Godunov’s scheme (upwind). The transport and Laplace equations are also forms in the field Numerical methods, the applications (a rod, a string, a drum, diffusion) forms in physics and chemistry. For conservation laws there are the schemes laxfriedrichs and muscl (with the minmod limiter) – for the transport and Burgers’ equation, the latter also with viscosity (compared with the Cole–Hopf transformation). The finite element method (fem) also works on a general polygon given by its vertices, polygon = (0,0), (2,0), …, with the boundary value u = …; the mesh comes from ear clipping and splitting the triangles. Heat in a plate is a form in physics.

The result is a graph of u(x, t): a curve in time with a slider and a play button, and a 3D surface to turn; a numerical solution has the exact one dashed. Laplace’s stationary u(x, y) is a 3D surface.

How to enter it

u_t = 4u_xx; u(0,t) = 0; u(π,t) = 0; u(x,0) = x(π - x)The equation, boundary and initial conditions; a derivative in a condition as u_t(x,0) or u_x(0,t).
u_t = u_xx; x ∈ ℝ; u(x,0) = e^(-x^2)The domain: x ∈ ℝ, x > 0 or 0 < x < π; without boundary conditions the whole line.
Δu = 0; r < 2; u(2,φ) = cos φLaplace’s equation in a disk: Δu, the radius r and the angle φ (or θ).
ftcs(u_t = u_xx; u(x,0) = sin(pi x); u(0,t) = 0; u(1,t) = 0; h = 0.1; k = 0.004; to = 0.1)Numerically: the scheme as the head, the steps h and k and the final time to.
adi(u_t = u_xx + u_yy; 0 < x < 1; 0 < y < 1; u(x,y,0) = x(1-x)y(1-y); T = 0.1)Heat in 2D: u(x,y,t), conditions like u(x,y,0) = … and u(0,y,t) = …; sides without a condition are 0.
fem(Δu = -4; polygon = (0,0), (2,0), (2,1), (1,1), (1,2), (0,2); u = 0; h = 0.25)Finite elements on a polygon: the vertices after polygon =, the boundary value u = …, the longest edge h.

Examples

A hyperbolic equation – characteristics, the canonical form u_ξη = 0 and the general solution.
Input: u_xx + 4u_xy + u_yy = 0
u_xx + 4u_xy + u_yy = 0
u_xx + 4u_xy + u_yy = 0u_xx + 4u_xy + u_yy = 0
Tricomi’s equation – the type by region.
Input: y u_xx + u_yy = 0
y u_xx + u_yy = 0
The transport equation by characteristics – the wave moves at the speed 2.
Input: u_t + 2u_x = 0; u(x,0) = e^(-x^2)
u_t + 2u_x = 0; u(x,0) = e^(-x^2)
u_t + 2u_x = 0; u(x,0) = e^(-x^2)u_t + 2u_x = 0; u(x,0) = e^(-x^2)
Heat in a rod with cooled ends – a Fourier series.
Input: u_t = 4u_xx; u(0,t) = 0; u(π,t) = 0; u(x,0) = x(π - x)
u_t = 4u_xx; u(0,t) = 0; u(π,t) = 0; u(x,0) = x(π - x)
u_t = 4u_xx; u(0,t) = 0; u(π,t) = 0; u(x,0) = x(π - x)u_t = 4u_xx; u(0,t) = 0; u(π,t) = 0; u(x,0) = x(π - x)
Ends at different temperatures – the steady state and the deviation from it.
Input: u_t = 2u_xx; u(0,t) = 1; u(2,t) = 3; u(x,0) = 0
u_t = 2u_xx; u(0,t) = 1; u(2,t) = 3; u(x,0) = 0
u_t = 2u_xx; u(0,t) = 1; u(2,t) = 3; u(x,0) = 0u_t = 2u_xx; u(0,t) = 1; u(2,t) = 3; u(x,0) = 0
A plucked string – standing waves.
Input: u_tt = 4u_xx; u(0,t) = 0; u(1,t) = 0; u(x,0) = x(1 - x); u_t(x,0) = 0
u_tt = 4u_xx; u(0,t) = 0; u(1,t) = 0; u(x,0) = x(1 - x); u_t(x,0) = 0
u_tt = 4u_xx; u(0,t) = 0; u(1,t) = 0; u(x,0) = x(1 - x); u_t(x,0) = 0u_tt = 4u_xx; u(0,t) = 0; u(1,t) = 0; u(x,0) = x(1 - x); u_t(x,0) = 0
Laplace’s equation on a rectangle with one heated side.
Input: u_xx + u_yy = 0; 0 < x < π; 0 < y < 1; u(x,1) = sin x
u_xx + u_yy = 0; 0 < x < π; 0 < y < 1; u(x,1) = sin x
u_xx + u_yy = 0; 0 < x < π; 0 < y < 1; u(x,1) = sin xu_xx + u_yy = 0; 0 < x < π; 0 < y < 1; u(x,1) = sin x
Laplace’s equation in a disk – a finite sum of harmonics.
Input: Δu = 0; r < 1; u(1,φ) = sin(φ)^2
Δu = 0; r < 1; u(1,φ) = sin(φ)^2
Δu = 0; r < 1; u(1,φ) = sin(φ)^2Δu = 0; r < 1; u(1,φ) = sin(φ)^2
d’Alembert’s formula – an initial pulse splits into two waves.
Input: u_tt = u_xx; x ∈ ℝ; u(x,0) = e^(-x^2); u_t(x,0) = 0
u_tt = u_xx; x ∈ ℝ; u(x,0) = e^(-x^2); u_t(x,0) = 0
u_tt = u_xx; x ∈ ℝ; u(x,0) = e^(-x^2); u_t(x,0) = 0u_tt = u_xx; x ∈ ℝ; u(x,0) = e^(-x^2); u_t(x,0) = 0
The Fourier transform on the whole line – a Gaussian profile widens.
Input: u_t = u_xx; x ∈ ℝ; u(x,0) = e^(-x^2)
u_t = u_xx; x ∈ ℝ; u(x,0) = e^(-x^2)
u_t = u_xx; x ∈ ℝ; u(x,0) = e^(-x^2)u_t = u_xx; x ∈ ℝ; u(x,0) = e^(-x^2)
The Laplace transform – a half-space heated, the function erfc.
Input: u_t = 4u_xx; x > 0; u(0,t) = 100; u(x,0) = 20
u_t = 4u_xx; x > 0; u(0,t) = 100; u(x,0) = 20
u_t = 4u_xx; x > 0; u(0,t) = 100; u(x,0) = 20u_t = 4u_xx; x > 0; u(0,t) = 100; u(x,0) = 20
The explicit scheme with r = 0.7 > 1/2 – unstable by von Neumann.
Input: ftcs(u_t = u_xx; u(x,0) = x(1-x); u(0,t) = 0; u(1,t) = 0; h = 0.1; k = 0.007; to = 1)
ftcs(u_t = u_xx; u(x,0) = x(1-x); u(0,t) = 0; u(1,t) = 0; h = 0.1; k = 0.007; to = 1)
ftcs(u_t = u_xx; u(x,0) = x(1-x); u(0,t) = 0; u(1,t) = 0; h = 0.1; k = 0.007; to = 1)ftcs(u_t = u_xx; u(x,0) = x(1-x); u(0,t) = 0; u(1,t) = 0; h = 0.1; k = 0.007; to = 1)
The Crank-Nicolson scheme with the Thomas algorithm.
Input: cranknicolson(u_t = u_xx; u(x,0) = sin(pi x); u(0,t) = 0; u(1,t) = 0; h = 0.1; k = 0.01; to = 0.1)
cranknicolson(u_t = u_xx; u(x,0) = sin(pi x); u(0,t) = 0; u(1,t) = 0; h = 0.1; k = 0.01; to = 0.1)
cranknicolson(u_t = u_xx; u(x,0) = sin(pi x); u(0,t) = 0; u(1,t) = 0; h = 0.1; k = 0.01; to = 0.1)cranknicolson(u_t = u_xx; u(x,0) = sin(pi x); u(0,t) = 0; u(1,t) = 0; h = 0.1; k = 0.01; to = 0.1)
The Lax-Wendroff scheme for the transport equation, the CFL condition.
Input: laxwendroff(u_t + u_x = 0; u(x,0) = e^(-50(x-0.3)^2); 0 < x < 1; h = 0.02; k = 0.016; to = 0.4)
laxwendroff(u_t + u_x = 0; u(x,0) = e^(-50(x-0.3)^2); 0 < x < 1; h = 0.02; k = 0.016; to = 0.4)
laxwendroff(u_t + u_x = 0; u(x,0) = e^(-50(x-0.3)^2); 0 < x < 1; h = 0.02; k = 0.016; to = 0.4)laxwendroff(u_t + u_x = 0; u(x,0) = e^(-50(x-0.3)^2); 0 < x < 1; h = 0.02; k = 0.016; to = 0.4)laxwendroff(u_t + u_x = 0; u(x,0) = e^(-50(x-0.3)^2); 0 < x < 1; h = 0.02; k = 0.016; to = 0.4)
The five-point scheme and SOR with the optimal ω – compared with Jacobi and Gauss-Seidel.
Input: sor(u_xx + u_yy = 0; u(x,1) = sin(pi x); u(x,0) = 0; u(0,y) = 0; u(1,y) = 0; h = 0.1)
sor(u_xx + u_yy = 0; u(x,1) = sin(pi x); u(x,0) = 0; u(0,y) = 0; u(1,y) = 0; h = 0.1)
sor(u_xx + u_yy = 0; u(x,1) = sin(pi x); u(x,0) = 0; u(0,y) = 0; u(1,y) = 0; h = 0.1)sor(u_xx + u_yy = 0; u(x,1) = sin(pi x); u(x,0) = 0; u(0,y) = 0; u(1,y) = 0; h = 0.1)
A heat source fading with time – Duhamel’s principle.
Input: u_t = u_xx + sin(x)e^(-t); u(0,t) = 0; u(π,t) = 0; u(x,0) = 0
u_t = u_xx + sin(x)e^(-t); u(0,t) = 0; u(π,t) = 0; u(x,0) = 0
u_t = u_xx + sin(x)e^(-t); u(0,t) = 0; u(π,t) = 0; u(x,0) = 0u_t = u_xx + sin(x)e^(-t); u(0,t) = 0; u(π,t) = 0; u(x,0) = 0
A constant heat source in a rod – the steady state is a parabola.
Input: u_t = u_xx + 1; u(0,t) = 0; u(1,t) = 0; u(x,0) = 0
u_t = u_xx + 1; u(0,t) = 0; u(1,t) = 0; u(x,0) = 0
u_t = u_xx + 1; u(0,t) = 0; u(1,t) = 0; u(x,0) = 0u_t = u_xx + 1; u(0,t) = 0; u(1,t) = 0; u(x,0) = 0
An insulated rod with heat flowing in at one end – the mean temperature grows linearly.
Input: u_t = u_xx; u_x(0,t) = 0; u_x(π,t) = 1; u(x,0) = 0
u_t = u_xx; u_x(0,t) = 0; u_x(π,t) = 1; u(x,0) = 0
u_t = u_xx; u_x(0,t) = 0; u_x(π,t) = 1; u(x,0) = 0u_t = u_xx; u_x(0,t) = 0; u_x(π,t) = 1; u(x,0) = 0
A string shaken at its end at its own frequency – resonance, the amplitude grows with t.
Input: u_tt = u_xx; u(0,t) = 0; u(π,t) = sin(t); u(x,0) = 0; u_t(x,0) = 0
u_tt = u_xx; u(0,t) = 0; u(π,t) = sin(t); u(x,0) = 0; u_t(x,0) = 0
u_tt = u_xx; u(0,t) = 0; u(π,t) = sin(t); u(x,0) = 0; u_t(x,0) = 0u_tt = u_xx; u(0,t) = 0; u(π,t) = sin(t); u(x,0) = 0; u_t(x,0) = 0
Laplace’s equation with an insulated bottom side (u_y = 0) – cosh instead of sinh.
Input: Δu = 0; u_y(x,0) = 0; u(x,1) = sin(pi x); u(0,y) = 0; u(1,y) = 0
Δu = 0; u_y(x,0) = 0; u(x,1) = sin(pi x); u(0,y) = 0; u(1,y) = 0
Δu = 0; u_y(x,0) = 0; u(x,1) = sin(pi x); u(0,y) = 0; u(1,y) = 0Δu = 0; u_y(x,0) = 0; u(x,1) = sin(pi x); u(0,y) = 0; u(1,y) = 0
Burgers’ equation – the characteristics cross and a shock wave forms.
Input: u_t + u u_x = 0; u(x,0) = e^(-x^2)
u_t + u u_x = 0; u(x,0) = e^(-x^2)
u_t + u u_x = 0; u(x,0) = e^(-x^2)u_t + u u_x = 0; u(x,0) = e^(-x^2)
Burgers’ equation with viscosity – the Cole-Hopf transformation into the heat equation.
Input: u_t + u u_x = 0.1u_xx; u(x,0) = -tanh(x)
u_t + u u_x = 0.1u_xx; u(x,0) = -tanh(x)
u_t + u u_x = 0.1u_xx; u(x,0) = -tanh(x)u_t + u u_x = 0.1u_xx; u(x,0) = -tanh(x)
Godunov’s scheme – the shock moves at the speed 1/2.
Input: upwind(u_t + u u_x = 0; u(x,0) = (1 - tanh(10x))/2; -2 < x < 4; h = 0.1; T = 2)
upwind(u_t + u u_x = 0; u(x,0) = (1 - tanh(10x))/2; -2 < x < 4; h = 0.1; T = 2)
upwind(u_t + u u_x = 0; u(x,0) = (1 - tanh(10x))/2; -2 < x < 4; h = 0.1; T = 2)upwind(u_t + u u_x = 0; u(x,0) = (1 - tanh(10x))/2; -2 < x < 4; h = 0.1; T = 2)
Heat in a square plate by ADI – stable even for a large step.
Input: adi(u_t = u_xx + u_yy; 0 < x < 1; 0 < y < 1; u(x,y,0) = sin(pi x)sin(pi y); h = 0.1; k = 0.01; T = 0.1)
adi(u_t = u_xx + u_yy; 0 < x < 1; 0 < y < 1; u(x,y,0) = sin(pi x)sin(pi y); h = 0.1; k = 0.01; T = 0.1)
adi(u_t = u_xx + u_yy; 0 < x < 1; 0 < y < 1; u(x,y,0) = sin(pi x)sin(pi y); h = 0.1; k = 0.01; T = 0.1)adi(u_t = u_xx + u_yy; 0 < x < 1; 0 < y < 1; u(x,y,0) = sin(pi x)sin(pi y); h = 0.1; k = 0.01; T = 0.1)
Laplace’s equation by conjugate gradients – compared with SOR and multigrid.
Input: cg(u_xx + u_yy = 0; u(x,1) = sin(pi x); u(x,0) = 0; u(0,y) = 0; u(1,y) = 0; h = 0.125)
cg(u_xx + u_yy = 0; u(x,1) = sin(pi x); u(x,0) = 0; u(0,y) = 0; u(1,y) = 0; h = 0.125)
cg(u_xx + u_yy = 0; u(x,1) = sin(pi x); u(x,0) = 0; u(0,y) = 0; u(1,y) = 0; h = 0.125)cg(u_xx + u_yy = 0; u(x,1) = sin(pi x); u(x,0) = 0; u(0,y) = 0; u(1,y) = 0; h = 0.125)
Poisson’s equation by multigrid – a few V-cycles on a fine grid.
Input: multigrid(u_xx + u_yy = -2; 0 < x < 1; 0 < y < 1; h = 0.0625)
multigrid(u_xx + u_yy = -2; 0 < x < 1; 0 < y < 1; h = 0.0625)
multigrid(u_xx + u_yy = -2; 0 < x < 1; 0 < y < 1; h = 0.0625)multigrid(u_xx + u_yy = -2; 0 < x < 1; 0 < y < 1; h = 0.0625)
The finite element method with triangles – the stiffness matrix and the same system as the five-point scheme.
Input: fem(u_xx + u_yy = -2; 0 < x < 1; 0 < y < 1; h = 0.25)
fem(u_xx + u_yy = -2; 0 < x < 1; 0 < y < 1; h = 0.25)
fem(u_xx + u_yy = -2; 0 < x < 1; 0 < y < 1; h = 0.25)fem(u_xx + u_yy = -2; 0 < x < 1; 0 < y < 1; h = 0.25)
Poisson’s equation on a square – a double Fourier series, compare with the sor scheme.
Input: Δu = -2; u(0,y) = 0; u(1,y) = 0; u(x,0) = 0; u(x,1) = 0
Δu = -2; u(0,y) = 0; u(1,y) = 0; u(x,0) = 0; u(x,1) = 0
Δu = -2; u(0,y) = 0; u(1,y) = 0; u(x,0) = 0; u(x,1) = 0Δu = -2; u(0,y) = 0; u(1,y) = 0; u(x,0) = 0; u(x,1) = 0
Derivatives on all four sides – the solvability condition and a solution up to a constant.
Input: u_xx + u_yy = 0; u_x(0,y) = 0; u_x(1,y) = 1; u_y(x,0) = 0; u_y(x,1) = -1 + cos(πx)
u_xx + u_yy = 0; u_x(0,y) = 0; u_x(1,y) = 1; u_y(x,0) = 0; u_y(x,1) = -1 + cos(πx)
u_xx + u_yy = 0; u_x(0,y) = 0; u_x(1,y) = 1; u_y(x,0) = 0; u_y(x,1) = -1 + cos(πx)u_xx + u_yy = 0; u_x(0,y) = 0; u_x(1,y) = 1; u_y(x,0) = 0; u_y(x,1) = -1 + cos(πx)
Variable coefficients – a Sturm–Liouville problem with the weight 1/x, eigenfunctions sin(n ln x).
Input: u_t = x^2u_xx + x u_x; u(1,t) = 0; u(e^π,t) = 0; u(x,0) = 1
u_t = x^2u_xx + x u_x; u(1,t) = 0; u(e^π,t) = 0; u(x,0) = 1
u_t = x^2u_xx + x u_x; u(1,t) = 0; u(e^π,t) = 0; u(x,0) = 1u_t = x^2u_xx + x u_x; u(1,t) = 0; u(e^π,t) = 0; u(x,0) = 1
The MUSCL scheme with a limiter – compare its error with the Lax–Wendroff and Lax–Friedrichs schemes.
Input: muscl(u_t + u_x = 0; u(x,0) = e^(-50(x-0.3)^2); 0 < x < 1; h = 0.02; k = 0.016; to = 0.4)
muscl(u_t + u_x = 0; u(x,0) = e^(-50(x-0.3)^2); 0 < x < 1; h = 0.02; k = 0.016; to = 0.4)
muscl(u_t + u_x = 0; u(x,0) = e^(-50(x-0.3)^2); 0 < x < 1; h = 0.02; k = 0.016; to = 0.4)muscl(u_t + u_x = 0; u(x,0) = e^(-50(x-0.3)^2); 0 < x < 1; h = 0.02; k = 0.016; to = 0.4)muscl(u_t + u_x = 0; u(x,0) = e^(-50(x-0.3)^2); 0 < x < 1; h = 0.02; k = 0.016; to = 0.4)
Burgers’ equation with viscosity by the MUSCL scheme – compared with the Cole–Hopf transformation.
Input: muscl(u_t + u u_x = 0.05u_xx; u(x,0) = (1 - tanh(x))/2; -5 < x < 5; T = 1)
muscl(u_t + u u_x = 0.05u_xx; u(x,0) = (1 - tanh(x))/2; -5 < x < 5; T = 1)
muscl(u_t + u u_x = 0.05u_xx; u(x,0) = (1 - tanh(x))/2; -5 < x < 5; T = 1)muscl(u_t + u u_x = 0.05u_xx; u(x,0) = (1 - tanh(x))/2; -5 < x < 5; T = 1)
Finite elements on an L-shaped domain – triangulation by ear clipping, the 3D surface over the domain only.
Input: fem(Δu = -4; polygon = (0,0), (2,0), (2,1), (1,1), (1,2), (0,2); u = 0; h = 0.25)
fem(Δu = -4; polygon = (0,0), (2,0), (2,1), (1,1), (1,2), (0,2); u = 0; h = 0.25)
fem(Δu = -4; polygon = (0,0), (2,0), (2,1), (1,1), (1,2), (0,2); u = 0; h = 0.25)fem(Δu = -4; polygon = (0,0), (2,0), (2,1), (1,1), (1,2), (0,2); u = 0; h = 0.25)

Known limitations