“Science is a differential equation. Religion is a boundary condition.”
Alan Turing
Differential equations are simultaneously often regarded as some of the coolest and strangest objects in physics. On one hand, they’re ubiquitous, and nearly every physics theory is expressed using them. On the other, they have a tendency to be unsolvable and difficult to understand. It is hoped that this chapter will bring all their positive qualities into the limelight, and make differential equations no longer scary or intimidating, but descriptions of nature unrivaled in their beauty.
The interpretation of this equation is that y increases proportional to its derivative, so as y increases, the rate of change of y increases by a proportional amount.
Differential equations can be of a single-variable function and its derivatives, or a multivariable function and its partial derivatives. For instance, the wave equation is given by:
Here, u=u(x,t), and is the function describing the wave. The interpretation of the wave equation is that the rate of change of the rate of change of u moving along the x direction is proportional to the rate of change of the rate of change of u as time passes.
Differential equations that only involve single-variable functions are called ordinary differential equations (ODEs), while those that involve multivariable functions (and their partial derivatives) are called partial differential equation (PDEs).
We are interested in solving differential equations to be able to perform further mathematical analysis of the physics of a given system. There are a myriad number of ways to solve differential equations, and we will cover just a few in the following sections. In general, however, finding an exact solution to a particular system cannot be done with knowledge of just the differential equation; typically, some data must be provided before a solution can be found.
In the case of ODEs in the form dtdy=f(t,y), this data is called the initial condition, the state of y(t) at t=0. Some physical examples of initial conditions are the initial velocity or initial position. We often denote such an initial condition y0. Once we know that, we can calculate the values of y that the differential equation predicts for all future times t. The combination of an ODE and an initial value is known as an initial-value problem (IVP).
Boundary-value problems can be thought of as an extension of initial value problems to partial differential equations (PDEs). Unlike initial counditions, boundary value problems usually specify the function that the solution to the PDE takes at the boundaries. Such functions are called boundary conditions (BCs). A physical example may be some water sloshing in a water tank; a PDE may be solved to find the function describing the distribution of water within the tank. The boundary condition would then be the height of the water at the walls of the tank.
The three main types of boundary conditions are Dirichlet, Neumann, and Robin. You can mix and use different boundary conditions together, especially for boundary-value problems that have different types of boundaries, but individually they are generally in one of these forms:
Type of BC
Example mathematical form
Dirichlet
y=f
Neumann
∂x∂y=f
Robin
Ay+B∂x∂y=f
Cauchy
Combination of Dirichlet and Neumann
Physical significance of different types of boundary conditions¶
The physical intepretation of a Dirichlet boundary condition is that the physical quantity is fixed or constrained at the boundary, that is, it takes a specific constant value. In the special case where u=0 at the boundary, the physical quantity vanishes at the boundary.
Meanwhile, the physical interpretation of a Neumann boundary condition is that the physical quantity is kept within the boundary. This corresponds to insulating or reflecting boundaries that prevent the physical quantity from flowing or radiating outwards.
Robin boundary conditions have more flexible physical interpretations. One specific type of robin boundaries is an open boundary. The physical interpretation of an open boundary condition is that the physical quantity is allowed to flow undisturbed outwards beyond the boundary. This corresponds to boundaries that allow for outward radiation or free propagation through them. It is a specific type of Robin boundary condition.
Initial-value problems can be solved by hand in some cases, but for cases where they cannot be solved by hand, computational methods can be used to solve them numerically (this results in an approximate solution). We will explore how to do so in the numerical methods section in Chapter 3. In addition, there exist online calculators that numerically solve differential equations: see Bluffton University’s free tool at this link for solving IVPs.
Boundary-value problems can be solved by hand in vastly fewer cases, and even when a solution is possible to find by hand, many simplifying assumptions must be used. For this reason, numerical methods are required for the majority of boundary-value problems. Again, we will explore this further in Chapter 3, but for those interested, the web app Visual PDE provides an easy-to-use graphical interface for solving PDEs numerically. We recommend you try it out!
When we are told to solve a differential equation, what we are doing is to figure out y from the differential equation. How we can do this depends on the type of differential equation. For example, consider an ODE in the form:
If we can put any ODE in this form, it is considered separable. What we can then do is to make sure each side of an equation is expressed only in terms of one variable:
Partial differential equations are considered separable by a similar criteria: if you can express each side of them only in terms of one variable, then they are separable.
But enough theory! Let’s actually try solving two differential equations, one ODE and one PDE. The ODE we will be solving is the exponential growth equation - the reason for that name will become apparent very soon. It is given by:
This is called the general solution to the exponential growth equation, because C2 can be any number, and so this general solution encodes all possible solutions each with their own value of C2.
To actually solve it for a value, we need an initial value. For instance, we may be told that y(0)=1. If we plug that in:
We have now solved the initial value problem - finding the solution to the differential equation given the provided initial condition.
Note that C2 was the same number as y(0). Therefore, we have a new interpretation of C2 - note that C2 is the initial value of a function, so C2=y0, and we can rewrite the general solution as:
where k and L are constants. This equation models the temperature function u(x,t) of a long, thin rod, where the value of u at a given position x and a given time t is the temperature. Third nice fact about the equation: it’s separable! To separate, we first write u(x,t) as a product of two functions:
This also applies applies to the boundary conditions as
u(0,t)=f(0)g(t)=0
u(L,t)=f(L)g(t)=0
These equations imply that one of two cofficients in each equation must be zero. Because the trivial solution is unacceptable, the function f(x) can not be equal to zero. Therefore, the new boundary conditions become
f(0)=f(L)=0
Going back to the new formation of the PDE using the separated functions, it can be rearranged into
This isolates the left side to functions of t and the right side to functions of x. Therefore, one variable changed, its side will change while the other would stay the same. Therefore, because this will violate their equality, both sides must the same. Therefore, they are both equal to a constant, −λ:
Why the negative sign? Since a negative sign applied to a constant makes it still a constant, so we can technically do what we want to λ - scale it, add another constant to it, make it positive or negative, the math still works out. The only difference is that −λ makes the resulting differential equations way easier to solve because λ will be positive once the new ODE is formed.
The introduction of the constant allows us to separate the PDE into two ODEs that easier to solve:
The first equation is a linear, second-order, homogeneous, constant-coefficient equation. Therefore, the solution is in the form f(x)=erx where r is an unknown constant. Then, by substituting this into the equation,
Because p>0 and L=0, this statement is invalid. Therefore, the second boundary condition isn’t satisifed and the case can not exist. Then, moving to the third case λ=0, so r=0. Therefore,
f(x)=A
Using both boundary conditions, f(x)=0. However, because this solution is the trivial solution, it is also invalid. Therefore, this case can not exist, thereby leaving the only valid case to be where λ<0. Therefore,
f(x)=sin(Lnπx)
where λ=Lnπ. Now, going back to the second equation from the original, g(t) is calculated as so
where C is an unknown constant of integration. Then, using the seperablility of u(x,t), it can calculated with product of the two solutions as so
u(x,t)=f(x)g(t)=Cexp(−kLnπt)sin(Lnπx)
Because n=1,2,…, there infinite number of solutions to the heat equation. Therefore, using the linearity of the equation, all the solutions can be combined into an infitie sum will form the ultimate solution of the equation as
u(x,t)=n=1∑∞Cnexp(−kLnπt)sin(Lnπx)
To solve for the unknown constant C, we will impliment the initial condition u(x,0)=f(x) to solution to get
u(x,0)=n=1∑∞Cnsin(Lnπx)=f(x)
Because the sine function is orthogonal to itself, ∫sin(Lnπx)sin(Lmπx)dx=0 with an integer m if m=n. Otherwise, ∫sin(Lnπx)sin(Lmπx)dx=2L. Using this information, we can multiply both sides of the equation by sin(mπxL) and integrate both sides with respect to x to eliminate the infinite number of sine functions. Once done, the equation reduces to
∫f(x)sin(Lmπx)dx=Cm2L
Because m equals the n in which the only constant is under, m be replaced with n in this equation and can rewritten to the solution
Suppose you must solve for y(t) for the inhomogeneous, initial value
problem
a2y′′+a1y′+a0y=f(t)
with some known initial conditions. There are several
ways to solve this problem, but one of them is through Laplace
Transformations. To define this, suppose f(t) is a piecewise smooth,
continuous function on 0<t<∞ such that ∣f(t)∣<Cekt for
some C>0 and k≥0, which bounds f(t) by exponential growth.
Therefore, the Laplace Transformation of f(t) is defined as
F(s)=L{f}(s)=∫0∞f(t)e−stdt
This solves the equation before by taking the Laplace Transformations
from each side, solving the Laplace transformation of y(t), noted as
Y(s), and taking the inverse Laplace transformation of both sides to
solve for y(t). To do the former, because of the repeatability of the
technique, there are many repeatable transformations listed as such:
To reverse the translated equation back to its original properties, an
inverse Laplace transformation must be used. The inverse Laplace
transform is defined such that L−1{F(s)}=f(t)
whenever L{f(t)}=F(s). The inverse Laplace transform
retains the properties of linearity and transformation respectively as
as well as reverse the operations displayed in the
table previously.
However, the perform the inverse Laplace transformation on the pervious
equation, it must be expanded using Partial Fraction Decomposition.
Suppose Q(s)P(s) such that degP<degQ. If
Q(s)=c(s−s1)(s−s2)…(s−sn), then
Q(s)P(s)=s−s1A1+s−s2A2+…+s−snAn
where Ai=lims→si(s−si)Q(s)P(s)=Q′(si)P(si)
for all i=1,2,…,n.
If Q(s)=c(s−s1)n1(s−s2)n2… where c is an
arbitrary constant, then
Let f(x) be defined for −L<x<L. The Fourier series of f(x),
F(x), is given by
F(x)=a0+n=1∑∞ancos(nx)+n=1∑∞bnsin(nx)
It is found in the solutions of many PDEs including
the heat equation, Laplace’s equation, and the wave equation, and its
coefficients can be solved using the orthogonality of sine and cosine
and are
An important property of a function of a Fourier Series is piecewise
smoothness. To explain, let f(x) be defined for x∈[a,b]. The
function is piecewise smooth if a finite partition of [a,b] exists
such that f(x) and f′(x) are continuous on each sub-interval of the
partition and that one-sided limits exist at the boundaries of the
sub-intervals.
This is important because this quality allows the Fourier Series to
converge into a periodic extension. If f(x) is piecewise smooth, then
the periodic extension of f(x) is the periodic repetition of f(x).
For example, if f(x)=x along −L<x<L, then its periodic extension
forms
import matplotlib.pyplot as plt
import numpy as np
L = 2
N = 3 # number of periods to display
samples_onethird = 50 # number of samples / 3
x = np.linspace(-N*L, N*L, samples_onethird*N)
x_original = np.linspace(-L, L, samples_onethird)
x_original[-1] = np.nan
y = np.tile(x_original, N)
plt.plot(x, y)
plt.grid()
plt.gca().set_aspect("equal")
plt.axhline(y=0, color='k')
plt.axvline(x=0, color='k')
plt.ylim(-2, 2)
plt.xlim(-N*L, N*L)
plt.show()
The Fourier Convergence Theorem states that if f(x) is piecewise
smooth along −L<x<L, the Fourier series of f(x) converges to the
periodic extension of f(x) where f(x) is continuous and the
mid-point of the one-side limits at each jump discontinuity. This allows
us to graph the function of Fourier Series and, by extension, the
solution of most PDEs.
If one of the coefficients of the summations in the original Fourier
Series F(x) were equal to zero, then the series would reduce into a
half-range series and the graph of the function changes. If the
summation with coefficients of sine functions remains, then the Fourier
Series transforms into a Fourier Sine Series and an odd function, which
means f(−x)=−f(x). On the other hand, if the summation with
coefficients of cosine functions, then the Fourier Series transforms
into transforms into a Fourier Cosine Series and an even function, which
mean f(−x)=f(x). To demonstrate this change, let
f(x)={2e−xx<0x≥0
where f(x) is a piecewise function for 1<x<−1. The Fourier
Series of f(x) converges to
# The function is y=2 x<0, y=e^{-x} x>0
eps = 0.01
L = 1
N = 3 # number of periods to display
samples_onethird = 200 # number of samples / 3
x = np.linspace(-N*L, N*L, samples_onethird*N)
x_original = np.linspace(-L, L, samples_onethird)
y_original = np.piecewise(x_original, [x_original< -eps, abs(x_original) <= eps, x_original>eps], [lambda x: 2, np.nan, lambda x: np.exp(-x)])
# Force breaks in curve via NaNs
y_original[-1] = np.nan
y_original[0] = np.nan
y = np.tile(y_original, N)
plt.plot(x, y)
plt.grid()
plt.gca().set_aspect("equal")
plt.axhline(y=0, color='k')
plt.axvline(x=0, color='k')
plt.show()
Then, the Fourier Sine Series of f(x) converges to
eps = 0.01
L = 1
N = 3 # number of periods to display
samples_onethird = 200 # number of samples / 3
x = np.linspace(-N*L, N*L, samples_onethird*N)
x_original = np.linspace(-L, L, samples_onethird)
y_original = np.piecewise(x_original, [x_original< -eps, abs(x_original) <= eps, x_original>eps], [lambda x: -np.exp(x), np.nan, lambda x: np.exp(-x)])
y_original[-1] = np.nan
y_original[0] = np.nan
y = np.tile(y_original, N)
plt.plot(x, y)
plt.grid()
plt.gca().set_aspect("equal")
plt.axhline(y=0, color='k')
plt.axvline(x=0, color='k')
plt.ylim(-1.5, 1.5)
plt.show()
and the Fourier Cosine Series of f(x) converges to
eps = 0.01
L = 1
N = 3 # number of periods to display
samples_onethird = 50 # number of samples / 3
x = np.linspace(-N*L, N*L, samples_onethird*N)
x_original = np.linspace(-L, L, samples_onethird)
y_original = np.exp(-abs(x_original))
y = np.tile(y_original, N)
plt.plot(x, y)
plt.grid()
plt.gca().set_aspect("equal")
plt.axhline(y=0, color='k')
plt.axvline(x=0, color='k')
plt.ylim(-1, 2)
plt.xlim(-N*L, N*L)
plt.show()
Another property of Fourier Series is Term-by-Term Differentiation. This
property is used to check the solutions of PDE and determines if an
infinite sum can be differentiated. For example, consider the heat
equation
ut=kuxx,0<x<L,t>0
with initial conditions
u(x,0)=f(x),0<x<L
and boundary conditions
u(0,t)=u(L,t)=0,t>0
The solution of the equation is the Fourier Series
If f(x) were piecewise smooth, then the Fourier Sine
Series converges to f(x) and for 0<x<L, u(x,0)=f(x). Therefore,
the initial condition is satisfied. When x=0,
u(0,t)=n=1∑∞Cnsin(0)=0
and when x=L,
u(L,t)=n=1∑∞Cnsin(nπ)=0
Therefore, the boundary conditions are satisfied. But,
is the PDE satisfied? Suppose
For this to be true for all n, the boundary condition
must be homogeneous. This is why not every Fourier Series can be
term-by-term differentiated. For example, let f(x)=x for 0<x<L,
which is piecewise smooth. Its Fourier Sine Series is
S(x)=n=1∑∞Bnsin(Lnπx)
where
Bn=L2∫0Lf(x)sin(Lnπx)dx=nπ2L(−1)n+1
By the Fourier Convergence Theorem, S(x)=f(x) for
0<x<L. However, consider term-by-term differentiation and take the
derivative of the Fourier Sine Series. Then,
Although the solution looks like it takes the form of
a Fourier Cosine Series, there are not enough additives such that
S′(x) deceases to zero as x approaches infinity. Therefore, S′(x)
does not converge and term-by-term differentiation can not be applied to
S(x). To determine if any function can be differentiated term-by-term,
let f(x) be defined for −L<x<L. f(x) can be differentiated
term-by-term if f(x) is continuous, f(−L)=f(L), and f′(x) is
piecewise smooth for −L<x<L. If f(x) is defined for 0<x<L, then
f(x) can be term-by-term differentiated if f(x) is continuous for
0≤x≤L and f′(x) is piecewise smooth. For Fourier Cosine and
Sine Series C(x) and S(x) respectively, term-by-term differentiation
is valid if f(0)=f(L)=0. This completes the section.
While many differential equations can be solved exactly, not all differential equations are so straightforward to solve. Instead, most differential equations are typically not solved directly.
There are three common alternatives if a differential equation is resistant to separation of variables or the Laplace and Fourier transforms:
“Guess and check”
Taylor series approximation
Numerical solving (often using computers)
The “guess and check” approach, also known as the “method of inspired guessing”, is literally that - given knowledge of functions and their derivatives, guess a solution to the differential equation. For instance, suppose we had the differential equation:
From basic analysis of this differential equation, we know that the original function must be of a degree less than 2, because otherwise its second derivative wouldn’t vanish to zero. Thus, we can guess that it is some type of linear function. And indeed, if we take the second derivative of a linear function, it does yield zero. So the solution is:
We can also use a Taylor series to approximate solutions to a differential equation. For instance, we could use it to approximate r(t) from Newton’s gravitational force equation:
We aim to solve this with a 4th-order Taylor series for the Earth and the Sun. We have the initial conditions r(0)=r0 and r′(0)=v0, where r0 is the mean distance from the Earth to the Sun (1 AU), and r′(0) is equal to T2πr0, where T is the Earth’s period. A 4th-order Taylor polynomial is given by:
This is 4th-order Taylor expansion for the solution r(t) of the differential equation, and will successfully approximate the solution, so long as t is close to zero.
The final method of solving differential equations that cannot be easily solved using any other means is by using numerical methods. Numerical methods take the initial conditions of a differential equation and calculate a tiny change dy in a function caused by a small step along the function’s input dx. Then, they add that little change dy to the existing value of y. By doing this process many, many times, over and over, an entire solution to a differential equation can be approximated.
To find the formula for one type of numerical method, the Euler method, consider the definition of the derivative, just with the limit removed:
This method is tedious to do by hand, but computers can do it very quickly. More accurate types of numerical methods, including the very popular Runge-Kutta methods, are similar in nature, only they break each step into smaller steps for more precision.
The great paradox of differential equations is that they can be ridiculously easy to solve, or ridiculously hard to solve. Using just pen-and-paper techniques, differential equations require lots of creativity and imaginative approaches to be solved, and often require simplifying the problem or special cases of problems. But with brute-force computer solving, differential equations can be simplified into much easier problems, albeit problems that require a lot of steps and computing power. In Project Elara, the majority of differential equation solving will be done numerically, but knowing the analytic techniques will certainly be helpful as well. That said, enough on differential equations - let’s get back into physics!