Note: This guide assumes prior knowledge of multivariable and some vector calculus, as well as basic knowledge of vectors and matrices. See Guide to multivariable and vector calculus if you need a refresher/introduction to these topics.
A partial differential equation or PDE is any equation that contains a function and its partial derivatives. The general form of a PDE is:
To shorten derivatives, we often use the symbol, where:
Some specific examples of PDEs include the heat equation:
The wave equation:
And Poisson’s equation:
PDEs can have many, many solutions. For instance, take the PDE:
The general solution of this PDE is . And yes, those can be any functions of , whether they be or or . Thus, just like ODEs need initial conditions to give unique solutions, PDEs need boundary conditions to give unique solutions. The typical set of boundary conditions for a PDE are values at the edges of the domain of the PDE (e.g. as ). When the PDE is dependent on time, then the boundary condition for is often called an initial condition - remember, for PDEs, initial conditions are considered a type of boundary condition.
Numerically solving PDEs
The most common methods of solving PDEs numerically are the finite difference, finite element, and boundary element methods. We will start with the finite difference method (FDM). The basic idea is to transform a PDE into a linear algebra problem by encoding derivatives as matrices. Take one-dimensional wave equation as example. It is given by:
We want to discretize the second partial derivative. Recall that the derivative is the limit of a difference quotient, which reads, in the discrete case, as:
Or, alternatively written:
This works in all cases except at the left and right boundaries of the domain, as there is not another point to the left of the boundary to take the central difference. Instead, we use the single-sided difference - for the left, we have:
And for the right, we have:
Note: see https://web.media.mit.edu/~crtaylor/calculator.html for a calculator for these values (enter 0, 1, 2, 3 for the left-handed 2nd derivative and -3, -2, -1, 0 for the right-handed 2nd derivative).
Now, partial derivatives are linear operators, just like matrices. So we can spatially discretize the equation by turning the 2nd spatial partial derivative into a matrix acting on the solution vector :
Where:
By discretizing the spatial derivative, the partial time derivative simply becomes an ordinary time derivative. Thus we can rewrite as:
Which is an ordinary differential equation that can be solved with conventional ODE solvers. The only thing left is to compute an initial condition and (if you know the initial condition you can differentiate it to get the initial time derivative).
This method works well even in the higher-dimensional case. For instance, consider the generalized wave equation:
By encoding the Laplacian as a matrix acting on , the same approach can be used as with the other approaches previously mentioned. In fact, this approach works for all linear partial differential equations that have one time and one or several space derivatives.
For other cases of linear PDEs that are not time-based, such as Poisson’s or Laplace’s equation, they can be generally written in the form:
And solved using standard linear algebra techniques for solving linear systems, of which there are many different solvers in popular libraries like NumPy, SciPy, Eigen, and others. Finally, for nonlinear PDEs, they can be generally written in the form:
Which is a rootfinding problem that can be solved with Newton’s method:
Solving vector differential equations
To solve vector differential equations, it is necessary to break up the vector differential equation into its components, and then solve for each of the components. For example, the first two of Maxwell’s equations result in 2 trivial equations. The second two are more complex, as the curl of a vector field produces another vector field. Thus, we must instead rewrite the curl component-by-component. The complete equations are:
So Maxwell’s equations result in 8 coupled PDEs. However, only 6 of them are independent - any system that satisfies the last 6 PDEs also must satisfy the first 2, so long as the boundary conditions satisfy the conservation of charge.
Here, note that for a solution, the current density must be set, which consists of one function each for .
The Maxwell equations are essential in our understanding of electromagnetism, and our work heavily depends on being able to solve them (both analytically and numerically), allowing us to analyze phenomena as diverse as electromagnetic waves to electron beams. See Solving for the fields in a hollow waveguide for an example.
List of common PDEs
This list contains a number of very common PDEs in physics, mathematics, and the sciences for reference purposes.
Wave equation:
Heat/diffusion equation:
Laplace’s equation:
Poisson’s equation:
Burger’s equation:
Continuity equation:
Navier-Stokes:
Maxwell’s equations (in vector form):
Einstein field equations:
Schrödinger equation:
Euler-Lagrange equations:
Hamilton’s equations:
Black-Scholes equation:
Sources and useful reading
- https://www.diva-portal.org/smash/get/diva2:1438836/FULLTEXT01.pdf
- https://youtu.be/hxGA1Je1P-s
- https://github.com/lukepolson/youtube_channel/blob/main/Python%20GPU/schrodinger.ipynb
- https://gist.github.com/c0rychu/6fc08cf5cdec2cc78a1f9334d103a869#file-schrodingereq_1d_tutorial-ipynb
- https://mathematica.stackexchange.com/questions/221207/finite-difference-method-for-1d-wave-equation
- https://nextjournal.com/sosiris-de/pde-2018
- https://empossible.net/wp-content/uploads/2019/08/Lecture-4a-Finite-Difference-Method.pdf
- https://aquaulb.github.io/book_solving_pde_mooc/solving_pde_mooc/notebooks/01_Introduction/01_00_Preface.html