2.2 Differential Equations

A differential equation is an equation that shows a relationship among derivatives. These derivatives may be multiplied by each other. They may also bare some relationship to the original function. There are many different types of differential equations. We will begin this section by reviewing differential equation classification.

Order

The order of a differential equation is the highest derivative within the differential equation. As an example, please consider equation 2.55.

y = d2y dx2 + 𝑑𝑦 𝑑𝑥 (2.55)

The highest derivative in equation is d2y dx2 . Therefore, this is a second order differential equation.

Partial vs. Ordinary

An ordinary differential equation is one composed of the derivatives of single variable functions. This type of derivative is introduced in section 2.1.1. Equation 2.56 shows an example of an ordinary differential equation.

y = d2y dx2 + 𝑑𝑦 𝑑𝑥 (2.56)

A partial differential equation is, as the name suggests, composed of partial derivatives. As a reminder from section 2.1.2, this means that we are dealing with derivatives of a multi-variable function. Equation 2.57 shows an example of a partial differential equation.

0 = ∂𝑧 ∂𝑥 + ∂𝑧 ∂𝑦 (2.57)

Linear vs. Non-Linear

A linear differential equation is a special type of ordinary differential equation that follows the following form shown in equation 2.58.

an(x)dny dxn + an1(x)dn1y dxn1 + ... + a1(x)𝑑𝑦 𝑑𝑥 + a0(x)y = g(x) (2.58)

In equation 2.58, y = f(x). The important thing to note in equation 2.58 is that all values y and all derivatives of y are to the first power. In addition, no derivatives of y are multiplied by y. Therefore, this equation is said to be linear in y. Please note that equation 2.58 accounts for the fact that the a coefficients could be 0, therefore eliminating the derivative of that order from the equation. So an equation that does not have a d2y dx2 term but has a d3y dx3 and 𝑑𝑦 𝑑𝑥 is still considered linear. Equation 2.59 shows an example of a linear differential equation.

cos(x)𝑑𝑦 𝑑𝑥 + x2y = cos2(x) + sin(2x) (2.59)

Equation 2.59 is linear in y.

A non linear differential equation is one that does not follow the listed rules. Equation 2.60 shows example of a non-linear differential equation.

cos(x) (𝑑𝑦 𝑑𝑥 )2 + x2y = cos2(x) + sin(2x) (2.60)

Second+ Order Homogeneous vs. Non-Homogeneous

There are two definitions of a homogeneous differential equation. The first definition applies to first order differential equations. We will not cover this definition, because it is very specific. The second definition of homogeneous differential equations applies to second+ order differential equations. A differential equation with the desired solution y = f(x) is said to be homogeneous if it follows the form shown in equation 2.61.

an(x)bn(y)dny dxn + an1(x)bn1(y)dn1y dxn1 + ... + a1(x)b1(y)𝑑𝑦 𝑑𝑥 + a0(x)b0(y) = 0 (2.61)

This is a similar equation as shown for linear differential equations. However, the important thing with homogeneous differential equations is that there is no g(x); there are no standalone functions of the dependent variable (which, in the y = f(x) functionality, is x).

An example of a homogeneous second order differential equation is shown in equation 2.62.

xd2y dx2 + y2 = 0 (2.62)

An example of a non-homogeneous second order differential equation is shown in equation 2.63.

xd2y dx2 + y2 = sin(x) (2.63)

Solving Differential Equations

As defined previously, a differential equation is simply a relationship of derivatives. Our goal is to decode this differential equation and find a function that satisfies it. In other words, if we are dealing with an ordinary differential equation, we want to find a function y = f(x) that, if plugged into the differential equation, holds true. If working with a partial differential equation, we want to find a function z = f(x,y,...) that, if plugged into the differential equation, holds true. I say “a” equation because theoretically, there could be multiple equations that serve as a solution to the differential equation. In the sections below we will go over methods for finding solutions to differential equations.

From section 2.1.1, we know that the derivative of a constant function is 0 (if the function is constant, its change must be 0). This, in effect, leads to a situation that each time we take a derivative of a function we loose information regarding any constant terms within the function. Let us take a step back; we are looking for functions which comply with a set of derivative relationships. There are infinite constant terms that can be added to any function and still comply with the derivative relationship defined in the differential equation. For example, 5x + 6 has the same derivative as 5x + 7. Typically, we lock these constant terms by including initial conditions or boundary conditions. Initial conditions, as the name suggests, specify the value of the function f or its derivatives when the independent variable is 0. Boundary conditions specify the value of the function f at given “boundary” values of the differential equation. The difference between initial conditions and boundary conditions can be nebulous when a boundary condition at 0 is specified. Therefore, the naming of these conditions can be thought of as a technicality and not a critical aspect to solving differential equations. When we have an 𝑛𝑡h order differential equation, this means we must differentiate our solution-function n times. Again, every time we differentiate we loose a constant term. Therefore, we need to have n initial conditions/boundary conditions for a differential equation of order n.

2.2.1 Direct Integration

Direct integration is a technique which can be used for first order ordinary differential equations which can be manipulated to the form shown in equation 2.64. Again, our goal is to find a equation y = f(x) that satisfies the given differential equation.

N(y)𝑑𝑦 𝑑𝑥 = M(x) (2.64)

N(y) is some function of y and M(x) is some function of x. In this case, we can just directly integrate equation 2.64 with respect to x. Doing this, we get equation 2.65.

N(y)𝑑𝑦 𝑑𝑥𝑑𝑥 =M(x)𝑑𝑥 (2.65)

The integral in equation 2.65 can be integrated using methods specified in section 2.1.5. Since this is a first order differential equation, we only need one initial condition to fully define its solution.

Short Example

Let us begin with the differential equation provided in equation 2.66.

2y𝑑𝑦 𝑑𝑥 = 3x2 + 4x 4 (2.66)

We will find a solution to equation 2.66 given the initial conditions provided in equation 2.67.

f(0) = 1 (2.67)

Using the method outlined in equation 2.65, we get the equation 2.68.

2y𝑑𝑦 𝑑𝑥𝑑𝑥 =3x2 + 4x 4𝑑𝑥 (2.68)

Integrating equation 2.68, we get equation 2.69.

y2 + c 1 = x3 + 2x2 4x + c 2 (2.69)

Both integrals generate a constant of integration. However, we could say that C = c2 c1. In this case, we are left with equation 2.70.

y = x3 + 2x2 4x + C (2.70)

Equation 2.70 shows the general solution. It holds true for any constant C. In order to specify this constant C, we plug in the initial conditions specified in equation 2.67. Doing this, we get C = 1. Therefore, our final solution is as shown in equation 2.71.

y = x3 + 2x2 4x + 1 (2.71)

2.2.2 Substitution

The substitution method can be used to solve linear (in the dependent variable, which in this book is y) homogeneous differential equations, with the stipulation that there may be no independent (x) variables within the equation. Therefore, these equations must be of the form shown in equation 2.72.

cndny dxn + cn1 dn1y dxn1 + ... + c1 𝑑𝑦 𝑑𝑥 + c0(y) = 0 (2.72)

In equation 2.72, cn is a known constant. To solve equation 2.72 using the substitution method, we start with the assumption shown in equation 2.73.

y = e𝜆𝑥 (2.73)

Assuming this, we can find the nth derivative of the above function using the chain rule (section 2.1.1.0) as shown in equation 2.74.

dny dxn = λne𝜆𝑥 (2.74)

Plugging equations generated using equation 2.74 into equation 2.72 we get equation 2.75.

cnλne𝜆𝑥 + c n1λn1e𝜆𝑥 + ... + c 1λ1e𝜆𝑥 + c 0e𝜆𝑥 = 0 (2.75)

Factoring out e𝜆𝑥, we get equation 2.76.

e𝜆𝑥 (c nλn + c n1λn1 + ... + c 1λ1 + c 0) = 0 (2.76)

By the zero product property, we can separate the terms in equation 2.76 generating equations 2.77 and 2.78.

e𝜆𝑥 = 0 (2.77)

cnλn + c n1λn1 + ... + c 1λ1 + c 0 = 0 (2.78)

Now, we know that e𝜆𝑥 can never equal 0. Therefore, we are left with equation 2.78. You may notice that this equation is simply a polynomial which we can solve for λ. We should get n “roots”, which are values for lambda. In order to find the solution to our differential equation, we plug all of these λ values back into equation 2.73. We then add all of these equations together. This is shown in equation 2.79.

y = C1eλ1x + C 2eλ2x + ... + C neλnx (2.79)

Equation 2.79 is the general solution; it has constants Cn. As expected, the number of constants matches the order of the differential equation. In order to find the value of these constants, we use the initial conditions.

Short Example

Let us start with the differential equation listed in equation 2.80.

d2y dx2 4𝑑𝑦 𝑑𝑥 12y = 0 (2.80)

The initial conditions are provided in equation 2.81.

f(0) = 1 𝑑𝑓(0) 𝑑𝑥 = 0 (2.81)

Following the prescribed methodology and arriving at the equation laid out by equation 2.78, we get equation 2.82.

λ2 4λ 12 = 0 (2.82)

Solving the polynomial in equation 2.82, we get values for lambda as shown in equations 2.83.

λ = 2,6 (2.83)

Therefore, per equation 2.79, our solution is shown in equation 2.84.

y = C1e2x + C 2e6x (2.84)

Using the initial conditions laid out in the problem statement (equation 2.81), we get C1 = 34 and C2 = 14. Therefore, our final solution is shown in equation 2.85.

y = 3 4e2x + 1 4e6x (2.85)

2.2.3 The Method of Undetermined Coefficients

The method of undetermined coefficients can be used to solve linear (in y) non-homogeneous differential equations with the stipulation that no functions of the independent variable (x) may be multiplied by the dependent variable (y) or its derivatives. Therefore, these equations must be of the form shown in equation 2.86.

cndny dxn + cn1 dn1y dxn1 + ... + c1 𝑑𝑦 𝑑𝑥 + c0(y) = g(x) (2.86)

The method of undetermined coefficients is simply a fancy way of saying “guessing”. Basically, we guess a function for y = f(x), differentiate as appropriate, and plug it into the given differential equation. Our goal is to formulate our guess so as to fulfill the differential equation; we want the left side (the one with all the derivatives) to equal g(x) when all the algebra is worked out. Guessing the appropriate function isn’t as hard as it seems. Table 2.1 shows recommended guesses for y = f(x) based on g(x).

Table 2.1: Best guesses for y = f(x) given g(x).
g(x) y = f(x) guess
ae𝛽𝑥 Ae𝛽𝑥
a cos 𝛽𝑥 A cos 𝛽𝑥 + B sin 𝛽𝑥
bsin𝛽𝑥 Acos𝛽𝑥 + Bsin𝛽𝑥
acos𝛽𝑥 + bsin𝛽𝑥 Acos𝛽𝑥 + Bsin𝛽𝑥
n𝑡h degree polynomial Antn + An1tn1 + ... + A1t + A0

In Table 2.1, a, b, and β are constants that are provided by g(x). Constants A, An and B are constants which must be solved for by plugging the y = f(x) guess into the given differential equation and ensuring the result equals g(x). The y = f(x) that ends up working is referred to as the particular solution and from this point onward will be referred to as yp.

Solving for the particular solution gives us a general solution to the differential equation. However, the particular solution alone has no integration constants. Therefore, while our particular solution is a solution to the differential equation, it is possible that it could not abide to the initial conditions. In order to find a differential equation that abides by the boundary conditions, we must find the homogeneous solution (the solution of equation 2.86 ignoring g(x)). This solution can be found using the method outlined above in section 2.2.2. From here on, we will refer to the solution of the homogeneous equation as yh. We then add yh to yp as shown below.

y = yh + yp (2.87)

Solving for the constants of yh using the boundary conditions, we will be left with an equation that works with the non-homogeneous original differential equation and also abides by the boundary conditions.

Short Example

Let us start with the differential equation shown in equation 2.88.

d2y dx2 4𝑑𝑦 𝑑𝑥 12y = 3e5x (2.88)

The initial conditions are provided in equations 2.89.

f(0) = 1 𝑑𝑓(0) 𝑑𝑥 = 0 (2.89)

Following the laid out order of steps, we start by finding the particular solution. Using equation 2.86 as the template, we know that g(x) = 3e5x. This means that g(x) is of the ae𝛽𝑥 form. From Table 2.1 we can tell that this means we should use Ae𝛽𝑥 as our guess. Plugging in y = Ae5x into equation 2.88, we get A = 37. This solution becomes our yp, as shown in equation 2.90.

yp = 3 7e5x (2.90)

You may notice that the homogeneous version of the differential equation at hand was solved in section 2.2.2.0. This solution (equation 2.84) is provided for sake of continuity.

yh = C1e2x + C 2e6x

Applying equation 2.87 we get equation 2.91 as our total solution.

y = C1e6x + C 2e2x 3 7e5x (2.91)

Now, it is time to solve for our constants of integration C1 and C2. Plugging in the initial conditions from equation 2.89, we get that C1 = 58 and C2 = 4556. Our final solution shown in equation 2.92.

y = 5 8e6x + 45 56e2x 3 7e5x (2.92)

2.2.4 The Laplace Transform

There are many real world uses of the Laplace Transform in electronic circuits, digital signal processing, and nuclear physics. However, this section is within the differential equation section because, within this book, we will go over the Laplace Transform simply as a tool to solve differential equations.

The Laplace transform is a way to transform a function which varies as a function of x (y = f(x)) to a different function which varies as a function of a new variable s (y = f(s)). The Laplace transform can be performed using equation 2.93 for a function y = f(x).

L(y) =0f(x) e𝑠𝑥𝑑𝑥 (2.93)

Table 2.2 shows the Laplace Transform of some common generic functions.

Table 2.2: Laplace transform of common functions.
𝐲 = 𝐟(𝐱) L(𝐲) = 𝐟(𝐬)
1 1 s
e𝑎𝑥 1 s a
xn, n = 1,2,3... n! sn+1
x π 2s32
sin(𝑎𝑥) a s2 + a2
cos(𝑎𝑥) s s2 + a2
tsin(𝑎𝑡) 2𝑎𝑠 (s2 + a2)2
tcos(𝑎𝑡) s2 a2 (s2 + a2)2
e𝑎𝑡 sin(𝑏𝑡) b (s a)2 + b2
e𝑎𝑡 cos(𝑏𝑡) s a (s a)2 b2
tne𝑎𝑡, n = 1,2,3... n! (s a)n+1

We are interested in taking the Laplace transform of differential equations. Therefore, it is helpful to find the Laplace transform of 𝑑𝑦 𝑑𝑥. This is shown in equation 2.94.

L (𝑑𝑦 𝑑𝑥 ) =0𝑑𝑦 𝑑𝑥 e𝑠𝑥𝑑𝑥 (2.94)

We can solve equation 2.94 using the integration by parts method laid out in section 2.1.5.0. Doing this, we get equation 2.95.

L (𝑑𝑦 𝑑𝑥 ) = [f(x) e𝑠𝑥] 00f(x) se𝑠𝑥𝑑𝑥 (2.95)

Since s does not vary as a function of x, we can take s out of the integral in equation 2.95. Doing this, it becomes apparent that the integral term matches the definition of L(y). It also becomes apparent that [f(x) e𝑠𝑥] 0, when evaluated using limits, becomes f(0). Therefore, equation 2.95 simplifies as shown in equation 2.96.

L (𝑑𝑦 𝑑𝑥 ) = sL (y) f(0) (2.96)

We can repeat the laid out procedure for a n order derivative to get equation 2.97.

L (dny dxn ) = snL (y) sn1f(0) ... dfn1(0) dxn1 (2.97)

The Laplace Transform can be used to solve linear (in y) non-homogeneous differential equations with the stipulation that no functions of the independent variable (x) are multiplied by the dependent variable (y) or its derivatives. Therefore, these equations must be of the form shown in equation 2.98.

cndny dxn + cn1 dn1y dxn1 + ... + c1 𝑑𝑦 𝑑𝑥 + c0(y) = g(x) (2.98)

Taking the Laplace transform of both sides and simplifying it is possible to get the general solution shown in equation 2.99.

L(y) = f(s) (2.99)

Plugging in equation 2.93 for L(y) we get equation 2.100.

0f(x) e𝑠𝑥𝑑𝑥 = f(s) (2.100)

Now, we want to go in reverse. We want to find what function y = f(x) gives us the given f(s). The process of finding the appropriate f(x) is done by guess and check. It is typically referred to as finding the inverse Laplace transform. The y = f(x) that works is the solution to our differential equation. You may notice that this process gives us the ability to solve the same types of differential equations as the processes presented in sections 2.2.2 and 2.2.3. However, the cool part about using the Laplace transform to solve differential equations is that, as shown in equation 2.97, solving for the initial conditions is included within the method.

Short Example

Let us start with the differential equation shown in equation 2.101.

d2y dx2 4𝑑𝑦 𝑑𝑥 12y = 3e5x (2.101)

With the initial conditions shown in equation 2.102.

f(0) = 1 𝑑𝑓(0) 𝑑𝑥 = 0 (2.102)

Our next step is to rewrite equation 2.101 as function of s. In other words, we want to take the Laplace Transform of equation 2.101. We can use Table 2.2 to find the Laplace transform 3e5x. We can use equation 2.97 to find the Laplace transform of the derivatives. Doing this, we get equation 2.103.

(s2L(y) 𝑠𝑓(0) 𝑑𝑓(0) 𝑑𝑥 ) 4 (sL(y) f(0)) 12L(y) = 3 s 5 (2.103)

Solving for L(y) we get equation 2.104.

L(y) = s2 9s + 23 (s 5)(s 6)(s + 2) (2.104)

Now, we need to take the inverse Laplace transform of equation 2.104. To do this, we can use partial fraction decomposition (section 2.1.5.0) to simplify as shown in equation 2.105.

L(y) = 5 8 ( 1 x 6 ) + 45 56 ( 1 x 5 ) 3 7 ( 1 x 5 ) (2.105)

Now, we can easily find the inverse Laplace transform of equation 2.105 using Table 2.2. Doing this, we are left with equation 2.106.

y = 5 8e6x + 45 56e2x 3 7e5x (2.106)

You may not notice that this is the same equation that was presented in section 2.2.3.0. You may also notice that we got the same answer when we used the Laplace Transform to solve the differential equation as when we used the method of undetermined coefficients (2.2.3.0) + substitution method (2.2.2). However, when doing the Laplace Transform method, we did not need to solve for our initial conditions.

2.2.5 Series Solutions to Differential Equations

The series solution method can be used to solve linear (in y) homogeneous equations. Such an equation is shown in it’s general form in equation 2.107.

an(x)dny dxn + an1(x)dn1y dxn1 + ... + a1(x)𝑑𝑦 𝑑𝑥 + a0(x)y = 0 (2.107)

As you may have observed, the big difference between this method and the methods outlined in sections 2.2.2 2.2.3, and 2.2.4 is that we can solve differential equations which have functions an(x) of the independent variable (x) multiplied by the dependent variable (y) or its derivatives (dny dxn).

We begin by assuming that a solution to the differential equation is an infinite series of the form shown in equation 2.108.

y = i=0c ixi (2.108)

In equation 2.108, ci is an arbitrary constant. The next step is to find the nth derivative of the equation shown in equation 2.108. There is no clean way to present the 𝑛𝑡h derivative of a series. Therefore, only the first two derivatives of equation 2.108 are shown in equations 2.109 and 2.110.

𝑑𝑦 𝑑𝑥 = i=1c i(i)xi1 (2.109)

d2y dx2 = i=2c i(i)(i 1)xi2 (2.110)

Please note that every time to we take the derivative, the resultant series starts at a different i to ensure we have no x terms with negative exponents. We can use the shown derivation pattern to recreate each term within our original differential equation (2.108) as a series. This is shown below in equation 2.111.

an(x)dny dxn = i=C1c i(f(i))xiN (2.111)

In equation 2.111, C1 depends on the desired first term of the series. f(i) stands for some function of i which is the simplified output that results from an(x) being multiplied by the derivative dependent series. N stands for some resulting exponent that results from the algebra of multiplying an(x)dny dxn. As can be deduced, our goal is to rewrite our differential equation as a series by plugging in the tailored terms. However, before we do this, we must ”shift” each series so it matches the format shown in equation 2.112.

an(x)dny dxn = i=C1c (i+N)(F(i))xi (2.112)

Notice that each series must be rewritten so that that it contains as xi, and not, for example, an xi1. Also, notice that the subscript of c changes from ci to c(i+N) when we shift the function, where N is the shift amount. f(i) has been changed to F(i) to emphasize that this coefficient term will change as a result of the shift.

Now we can plug each tailored individual series into the differential equation. Since each series has been shifted to have the term xi, we can rewrite our entire differential equation as one big series by combining the series of each term within the differential equation. Essentially, we are plugging each individual 2.112 into equation 2.107. Doing this, we will get something which resembles equation 2.113.

i=C1c (i+N)(G(i))xi = 0 (2.113)

In equation 2.113, G(i) is the result of all the F(i) terms being added together. A solution to the differential equation is found when the ci+N values can be found in terms of cK, where ck stands for the constant of integration terms. For more details as to how to do this, please reference the following example.

Short Example

Let us start with the differential equation shown in equation 2.114.

d2y dx2 𝑥𝑦 = 0 (2.114)

Now, in following the laid out procedure, we assume equation 2.108. Therefore, we obtain equations 2.115 and 2.116.

d2y dx2 = i=2c i(i)(i 1)xi2 (2.115)

𝑥𝑦 = i=1c ixi+1 (2.116)

Now, we want to shift each series so that it is composed of xi and its coefficients. Doing this, we get equations 2.117 and 2.118.

d2y dx2 = i=2c (i+2)(i + 2)(i + 1)xi (2.117)

𝑥𝑦 = i=0c (i1)xi (2.118)

Plugging equations 2.117 and 2.118 into our original differential equation (equation 2.114), we get equation 2.119.

i=0c (i+2)(i + 2)(i + 1)xi i=1c (i1)xi = 0 (2.119)

In order to get both sums to start at i = 1 and combine them, we can take out the i = 0 term from the first sum as shown in equation 2.120.

2 c2 + i=1[c (i+2)(i + 2)(i + 1)xi c (i1)] xi = 0 (2.120)

Now, we need to find coefficient (c) terms for which equation 2.120 is true. Since equation 2.120 must equal 0 for all values of x, we know that the coefficients of each xi must add up to be zero. Let us begin by looking at the coefficient of x0. Plugging i = 0 into equation 2.120 we get equation 2.121.

2 c2 = 0 (2.121)

Therefore, we know equation 2.122 must be true.

c2 = 0 (2.122)

Now, for the coefficients of x1,x2,...,xi we can repeat a similar process to get equation 2.123.

c(i+2) = c(i1) (i + 2)(i + 1) (2.123)

Now we plug in sequential values of i to solve for the ci terms at different values of i. We know that this is a second order differential equation. Therefore, we should theoretically be able to find all coefficients in terms of two constants (which would be the constants of integration). Since the series used to define the above relationship starts at i = 1, we must start plugging in values starting at i = 1. This is done up until i = 6.

c3 = c0 (3)(2) c4 = c1 (4)(3) c5 = c2 (5)(4) = 0 c6 = c0 (6)(5)(3)(2) c7 = c1 (7)(6)(4)(3) c8 = c2 (8)(7)(5)(4) = 0

As you can observe, as we iterate up in i we can plug in coefficients that arise from previous i values. Given the ci values, our initial assumption of equation 2.108 can be rewritten as equation 2.124.

y = c0 + c1x + c0 (3)(2)x3 + c1 (4)(3)x4 + c0 (6)(5)(3)(2)x6 + c1 (7)(6)(4)(3)x7 + .... (2.124)

In equation 2.124, every ci can was written as a function of either c0 or c1. As expected, these are our two constants of integration. Consolidating equation 2.124 using the sum symbol, we get equation 2.125.

y = c0 (1 + i=1 x3i (3i)(3i 1) ... (6)(5)(3)(2) ) + c1 (x + i=1 x3i+1 (3i + 1)(3i) ... (7)(6)(4)(3) ) (2.125)

2.2.6 Series Solutions to Cauchy Euler Differential Equations

Cauchy Euler differential equations are linear (in x and y), ordinary, homogeneous differential equations of the form shown in equation 2.126.

axndny dxn + ... + bx2 d2y dx2 + 𝑐𝑥𝑑𝑦 𝑑𝑥 + 𝑑𝑦 = 0 (2.126)

As can be deduced, if we try to solve the above equation using series solutions (section 2.2.5) we will get a bunch of terms to the x0 power. Therefore, we cannot use this method. Rather, we assume our solution is of the form shown in equation 2.127.

y = xm (2.127)

Assuming this, as in section 2.2.2, we can find the nth derivative of the function in equation 2.127 as shown in equations 2.128 and 2.129. There is no clean way to present the nth derivative of equation 2.127. Therefore, only the first two derivatives are provided.

𝑑𝑦 𝑑𝑥 = mxm1 (2.128)

y = (m)(m 1)x(m2) (2.129)

Plugging equations 2.128 and 2.129 into our original differential equation (equation 2.126) and factoring out xm we get equation 2.130.

xm(f(m)) = 0 (2.130)

By the zero product property, we can state equations 2.131 and 2.132.

xm = 0 (2.131)

f(m) = 0 (2.132)

Now, we know that xm can never equal 0. However, we can solve the f(m) = 0 equation, which will be a polynomial. Doing this, we get m values m1, m2, ... mn. Therefore, our final solution will be of the form shown in equation 2.133.

y = C1xm1 + C2xm2 + ... + Cnxmn (2.133)

2.2.7 Short Example

Let us start with the differential equation shown in equation 2.134.

x2 d2y dx2 + x𝑑𝑦 𝑑𝑥 4y = 0 (2.134)

With the initial conditions provided in equation 2.135.

f(1) = 1 𝑑𝑓(1) 𝑑𝑥 = 0 (2.135)

Assuming equation 2.127 and plugging in with accordance to the above process, we get equation 2.136.

xm [(m)(m 1) + m 4] = 0 (2.136)

In following the process, we solve the f(m) term for m. Doing this, we get m = ±2. Therefore, our general solution is shown in equation 2.137.

y = C1x2 + C 2x2 (2.137)

Plugging in our initial conditions, we find that C1 = C2 = 1 2. Therefore, the final solution is shown in equation 2.138.

y = 1 2x2 + 1 2x2 (2.138)

2.2.8 Separation of Variables

The separation of variables method can be used to solve partial differential equations. There is no general rule for the form these equations must have to be solved using this method. However, within engineering, we use this method to solve equations of general format shown in equations 2.139 and 2.140.

k1 d2z dx2 + k2d2z dy2 = 0 (2.139)

k1 d2z dx2 + k2𝑑𝑧 𝑑𝑦 = 0 (2.140)

Equation 2.139 is called the 2D Laplace’s equation if we assume k1 and k2 to be positive. If k2 is negative equation 2.139 resembles the general form the wave equation, which is not covered in this book. Equation 2.140 resembles the general form of the 1D heat equation, derived in section ??. We will solve this equation using the separation of variables method in the example.

The separation of variables is based upon, as the name suggests, separating the variables in the partial differential equation. The solution to both equations 2.139 and 2.140 is some function z = f(x,y). When we apply the separation of variables method, we assume that the solution is of the form shown in equation 2.141.

z = F(x) G(y) (2.141)

In other words, we are assuming that the solution to our partial differential equation is some function of just x (F(x)) multiplied by some function of just y (G(y)). In following the pattern of this differential equations section, finding solutions to differential equations is a creative guessing game. We assume equation 2.141 simply because it ends up working.

Now that we have assumed the format of our solution, we can recreate each term within our original partial differential equation by the taking the partial derivative (2.1.2) of equation 2.141 n times. This process is not not dissimilar from the one presented in section 2.2.5. Rewriting our differential equation using our assumption we will get a new differential equation which resembles equation 2.142.

k1G(y)dn(F(x)) dxn + k2F(x)dn(G(y)) dy2 = 0 (2.142)

Now, our goal is to algebraically manipulate the equation so that each side of the equation is a function of x (F(x)) and its derivatives and the other side of the equation is a function of y (G(y)) and its derivatives. Doing this, we will get equation 2.143.

k1 F(x) dn(F(x)) dxn = k2 G(y) dn(G(y)) dy2 (2.143)

The negative was eliminated from equation 2.143 since k2 and/or k1 can be positive or negative.

Now, if you look closely at equation 2.143, you might notice something peculiar. We have a output on the left side that is purely a function of x. We have an output on the right side that is purely a function of y. For every x and y, these outputs are equal to each other. How could this be possible? The only way this could be possible is if both these outputs are equal to a constant. We will call this constant Ω. This is concept is shown in equation 2.144.

k1 F(x) dn(F(x)) dxn = k2 G(y) dn(G(y)) dy2 = Ω (2.144)

Ω can be positive or negative depending on the downstream necessity.

Given this conceptual realization, we can rewrite equation 2.144 as shown in equations 2.145 and 2.146.

dn(F(x)) dxn Ω F(x) k1 = 0 (2.145)

dn(G(y)) dy2 Ω G(y) k2 = 0 (2.146)

You may notice that we have taken our partial differential equation and turned it into two ordinary differential equations. Equations 2.145 and 2.146 can be solved for given initial conditions/boundary values using methods outlined in sections 2.2.2 2.2.3, and 2.2.4. When we are done solving for G(y) and F(x) we simply multiply them together in accordance with equation 2.141 to obtain the solution to our partial differential equation.

Short Example: The Heat Equation / Diffusion equation

In this section, we will solve the 1D version of the diffusion equation (equation ??), which is in the same form as the heat equation (equation ??) assuming no internal heating. The derivation for the diffusion equation can be found in section ??, while the derivation of the heat equation can be found in section ??. Rewriting equation 2.140 with the relevant variables we get equation 2.147.

kd2T dx2 = 𝑑𝑇 𝑑𝑡 (2.147)

The initial condition is provided in equation 2.148.

T(x,0) = 6sin (𝜋𝑥 L ) (2.148)

The boundary conditions are provided in equation 2.149.

T(0,t) = 0 T(L,t) = 0 (2.149)

In linking equation 2.147 to equation ?? for diffusion, T stands for concentration, and t stands for time. k is equal to D, the diffusion coefficient. In linking equation 2.147 to equation ?? for heat, T stands for temperature and t stands for time. k is equal to K cpρ, where K is thermal conductivity (section ??), cp is specific heat (section ??), and ρ is density. The initial conditions state that at time t = 0 the object has the concentration / temperature distribution f(x). The boundary conditions state that no matter what the time (t), the concentration/temperature at either end of the object is 0.

In following the process laid out, we begin by assuming the multi-variable solution to our differential equation (T = f(x,t)), will be a product of function F(x) and function G(t).

T = F(x) G(t) (2.150)

We then take the partial derivative (2.1.2) of equation 2.150 as to plug it into our original differential equation (2.147). Doing this, we get equation 2.151.

𝑘𝐺(t) d2F dx2 = F(x) 𝑑𝐺 𝑑𝑡 (2.151)

Reordering so that each side of the equation has like terms, we get equation 2.152.

1 F(x) d2F dx2 = 1 𝑘𝐺(t) 𝑑𝐺 𝑑𝑡 (2.152)

Now we can assume the relationship laid out in equation 2.144. Doing this, for the left hand term, we get the ordinary differential equation shown in equation 2.153.

1 F(x) d2F dx2 + ΩF(x) = 0 (2.153)

We know that for function T to abide by the global initial and boundary conditions, F(x) must abide by the boundary conditions shown in equation 2.154.

F(0) = 0 F(L) = 0 (2.154)

We need to assume that Ω is positive/negative in accordance with what makes our math later on work out. In this case, Ω is kept positive. Solving this equation using the method outlined in section 2.2.2 we get equation 2.155.

F(x) = C1e𝑖𝑥Ω + C 2e𝑖𝑥Ω (2.155)

Using equation 2.255, equation 2.155 can be rewritten as equation 2.156.

F(x) = C1 sin(xΩ) + C2 cos(xΩ) (2.156)

Now, plugging in the first boundary condition shown in equation 2.149, we get that C2 = 0. Plugging in the second boundary condition shown in equation 2.154, we get that Ω = (𝑛𝜋 L ) 2. n can equal any positive integer. Therefore, we are left with equation 2.157.

F(x) = C1 sin (𝑥𝑛𝜋 L ) (2.157)

From the right hand term of equation 2.152 we get equation 2.158.

𝑑𝐺 𝑑𝑡 + Ω𝑘𝐺(t) = 0 (2.158)

Solving equation 2.158 using the method outlined in section 2.2.2 we get equation 2.159.

G(t) = C3ek(𝑛𝜋 L )2t (2.159)

Please note that we plugged in Ω = (𝑛𝜋 L ) 2. Plugging in equation 2.157 and 2.159 into equation 2.150 we get equation 2.160.

T(x,t) = Bnek(𝑛𝜋 L )2t sin (𝑥𝑛𝜋 L ) with n = 0,1,2,3... (2.160)

Please note that the generalized constant Bn = C1 C3. Equation 2.160 would theoretically work for any positive integer n. Bn signifies that the constant B will probably be different at every n used.

Now, our last step is to solve for Bn. This equation is dependent upon our initial conditions. Plugging in equation 2.148 to equation 2.160 we can see that one obvious solution exits at n = 1 and B1 = 6. Therefore, our final solution is shown in equation 2.161.

T(x,t) = 6ek(π L )2t sin (𝑥𝜋 L ) (2.161)

2.2.9 Numerical Methods: Finite Difference

The previous differential equation sections overviewed methods that provide us with analytical solutions to differential equations. These methods output a clean equation which defines the solution (symbolized by f(x)) as a function of the independent variable (typically x). In this section, we will use a method called the finite difference method to generate values that constitute the solution data-set (i.e. a numerical solution). To do this, we must choose values of the independent variable at which we will calculate our solution. Within this section, these chosen values are symbolized by xj, with j being an integer value. xj+1 xj represents increment between independent variable values at which we calculate the solution to the differential equation, and within this section is symbolized by Δx (i.e. xj + Δx = xj+1). As follows, the solution to the differential equation at a given xj is written as f(xj). In this section, we will shorten f(xj) to fj (i.e. f(xj) = fj).

In general, generation of a solution data set to a differential equation by use of the finite difference method is a three step process. First, we must approximate the differential terms in a differential equation using an finite difference approximation (an algebraic simplification). Secondly, we must plug our approximation into the differential equation. Lastly, we solve the differential equation based of the initial conditions given the substituted finite difference approximation. In this section, we will first focus on the first step of using the finite difference method and present a number of common finite difference approximations used to generate numerical solutions to differential equations. We will go over the errors for each approximation. We will also go over one advanced approximation called RK4. Then, we will cover the second and third steps of using the finite difference method by plugging in our approximation and numerically solving two example differential equations.

Forward difference

The forward difference approximation for the derivative at xj is provided in equation 2.162.

dfj 𝑑𝑥 = fj+1 fj Δx (2.162)

To find the error associated with the forward difference approximation, we can start out by writing out the Taylor series (the Taylor series will be discussed in section 2.5.1) for fj+1 centered at fj. This is shown in equation 2.163.

fj+1 = fj + dfj 𝑑𝑥 (xj+1 xj) + 1 2 d2fj dx2 (xj+1 xj) 2 + 1 6 d3fj dx3 (xj+1 xj) 3 + ... + 1 n! dnfj dxn (xj+1 xj) n (2.163)

Subtracting fj from both sides and dividing by xj+1 xj, we get equation 2.164.

fj+1 fj Δx = dfj 𝑑𝑥 + 1 2 d2fj dx2 Δx + 1 6 d3fj dx3 Δx2 + ... + 1 n! dnfj dxn Δxn1 (2.164)

Please note that in equation 2.164 xj+1 xj was substituted with Δx. Subtracting all terms except for dfj 𝑑𝑥 from the right hand side of equation 2.164 and then flipping the equation we get equation 2.165.

dfj 𝑑𝑥 = fj+1 fj Δx 1 2 d2fj dx2 Δx 1 6 d3fj dx3 Δx2 ... 1 n! dnfj dxn Δxn1 (2.165)

Comparing equation 2.165 to equation 2.162, we see that the 1 2 d2f j dx2 Δx 1 6 d3f j dx3 Δx2 ... 1 n! dnf j dxn Δxn1 terms are all error terms. Therefore, we can rewrite equation 2.165 as equation 2.166.

dfj 𝑑𝑥 = fj+1 fj Δx + ert (2.166)

With ert defined in equation 2.167.

ert = 1 2 d2fj dx2 Δx 1 6 d3fj dx3 Δx2 ... 1 n! dnfj dxn Δxn1 (2.167)

1 2 d2f j dx2 Δx is referred to as the leading truncation term. The order of a given numerical method is defined by the power of the Δx of the leading truncation term. For forward difference, we see that the Δx of our leading truncation term is to the 1st power (i.e. Δx1). Therefore, the forward difference approximation is considered first order.

Backward difference

The backward difference approximation for the derivative at xj is provided in equation 2.168.

dfj 𝑑𝑥 = fj fj1 Δx (2.168)

To find the error associated with the backwards difference approximation, we will follow the same process as we did for forward difference by writing out the Taylor series for fj1 centered at fj. Doing this we get equation 2.169.

fj1 = fj + dfj 𝑑𝑥 (xj xj1) + 1 2 d2fj dx2 (xj xj1) 2 + 1 6 d3fj dx3 (xj xj1) 3 + ... + 1 n! dnfj dxn (xj xj1) n (2.169)

Solving for dfj 𝑑𝑥 and replacing xj xj1 with Δx we get equation 2.170.

dfj 𝑑𝑥 = fj fj1 Δx + ert (2.170)

With ert provided in equation 2.171.

ert = 1 2 d2fj dx2 Δx 1 6 d3fj dx3 Δx2 + ... + 1 n! dnfj dxn (Δx)n1 (2.171)

From equation 2.171 we see that the leading truncation term is 1 2 d2f j dx2 Δx. Therefore, just as with forward difference backwards difference is a first order approximation.

Central difference

The central difference approximation for the derivative at xj is provided in equation 2.172.

dfj 𝑑𝑥 = fj+1 fj1 2Δx (2.172)

To find the error associated with the central difference approximation, we can add the Taylor series for fj+1 (equation 2.163) to the Taylor series for fj1 (equation 2.169) with both series centered at fj. Doing this and simplifying, we get equation 2.173.

dfj 𝑑𝑥 = fj+1 fj1 2Δx + ert (2.173)

With ert provided in equation 2.174.

ert = 1 6 d3fj dx3 Δx2 + H.O.T (2.174)

In equation 2.174, H.O.T stands for higher order terms. In contrast to forward and backward difference, we see that our leading truncation term has the Δx to the power of 2. Therefore, central difference is a second order approximation.

Second order central difference

The second order in second order central difference does not refer to the order of the leading truncation term, but rather that this approximation is used for the second derivative of xj as shown in equation 2.175.

d2fj dx2 = fj+1 2fj + fj1 Δx2 (2.175)

The second order central difference approximation has a second order leading truncation term. Because it is laborious, the steps to get to this conclusion are not provided. However, the reader is invited to prove this to her/himself using the process shown in the previous forward, backwards, and central difference approximation sections.

Runge–Kutta 4 (RK4)

Runge-Kutta is a general name used to describe a family of finite different approximations. These approximations are advanced. Therefore, we will not review the definition and derivation of the Runge-Kutta approximation. Instead, we will present how to utilize a common Runge-Kutta approximation, called Runge-Kutta 4 or RK4 for short. In contrast to the previously presented methods, we will not present a approximation for a derivative of f which then must be plugged into an equation. Rather we will jump directly to solving for fj+1 therefore giving us our solution.

To utilize the RK4 method, we first start by assuming we have a first order differential equation of the form shown in equation 2.176.

dfj 𝑑𝑥 = g(fj,xj) (2.176)

Essentially, we are stating that the derivative of f(xj) is equal to some function g of fj and xj. We then state that fj+1 can be found using equation 2.177.

fj+1 = fj + Δx 6 (k1 + 2k2 + 2k3 + k4) (2.177)

With k1, k2, k3, and k4 defined in equation 2.178.

k1 = g(xi,fj) k2 = g (xi + Δx 2 ,fj + Δx k1 2 ) k3 = g (xi + Δx 2 ,fj + Δx k2 2 ) k4 = g (xi + Δx 2 ,fj + Δx k3) (2.178)

As the name suggests, 𝑅𝐾4 has a fourth order leading truncation term.

Differences between approximations

As touched on when reviewing finite difference approximations, one difference between methods is the order of the leading truncation term. Since the order refers to the exponent of Δx multiplied by the first term of the error function, higher order leading truncation terms have a lower error than lower order leading truncation terms. Another big difference between methods is the stability. Depending on the method used, specific values of Δx can make the finite difference approximation unstable and produce an erroneous result. Stability analysis is a major topic in numerical methods; to learn more about this the reader is referred to an numerical methods textbook. The last consideration to make when choosing a given finite difference approximation is whether a given approximation is implicit or explicit. For initial value problems, only the initial condition is provided, meaning that fi+1 must be calculated based on fj. Therefore, it is helpful to have an equation of the form fj+1 = g(fj,xj) (i.e. it is possible to solve for fj+1). However, with some methods (such as backwards difference) this is impossible, and fj+1 must be found using implicit methods.

Example: Ordinary differential equation

In this example, we will use the forward difference approximation to generate a data set for the differential equation provided in equation 2.88. For continuity, this equation is provided here and relabeled as equation 2.179. Please note that in order to remain consistent with the notation in this section the y in equation 2.88 was replaced with f(x).

d2f dx2 4 𝑑𝑓 𝑑𝑥 12f(x) = 3e5x (2.179)

The initial conditions for this example are provided in equations 2.180.

f(0) = 1 𝑑𝑓(0) 𝑑𝑥 = 0 (2.180)

It is now time to plug in our finite difference approximations. Since we are using forward difference, we can plug in the forward difference approximation (equation 2.162) for 𝑑𝑓 𝑑𝑥. We must still plug in an approximation for d2f dx2 . The reader may be tempted to plug in the second order central difference approximation (equation 2.175). However, the reader will then subsequently notice that the second order central difference approximation has a fi+2 term for which we cannot solve. So, we move to do a different clever trick. We will convert equation 2.179 to become a system of two first order coupled differential equations. We can do this by introducing a new function u(x) defined as shown in equation 2.181.

u(x) = 𝑑𝑓 𝑑𝑥 (2.181)

Substituting u(x) (equation 2.181) into equation 2.179 we get two coupled differential equations shown in equation 2.182.

{ 𝑑𝑓 𝑑𝑥 = u(x) 𝑑𝑢 𝑑𝑥 = 4u(x) + 12f(x) + 3e5x (2.182)

We can find the initial condition for our coupled first order differential equation by substituting equation 2.181 in for the 𝑑𝑓 𝑑𝑥 initial condition shown in equation 2.180. Doing this, we get our new initial conditions as shown in equation 2.183.

f(0) = 1 u(0) = 0 (2.183)

Now, we can plug in our forward difference approximation (equation 2.162) for 𝑑𝑓 𝑑𝑥 and 𝑑𝑢 𝑑𝑥. Doing this, and solving for fj+1 and uj+1 we get equation 2.184.

{fj+1 = uj Δx + fj uj+1 = (4uj + 12fj + 3e5xj ) Δx + uj (2.184)

In following the notation used in this section, fj is simply a shortened way of writing f(xj) and uj is simply a shortened way of writing u(xj). Investigating equation 2.184 closely, you may notice that we can solve for f1 and u1 by simply plugging in our initial conditions which provide values for f0 (same as f(0)) and u0 (same as u(0)) in equation 2.183. We can then use the f1 and u1 to solve for f2 and u2. This is great news! We can now build a solution f(x) by ”marching forward”. This is best done using a coding software such as MATLAB or python, but excel can be used as well. Figure 2.4 shows a solution dataset using the Foward Euler approximation for Δx = .1 and Δx = .01. The analytical ”ground truth” solution from equation 2.92 is provided as a comparison.

PIC

Figure 2.4: Forward Euler approximation for the solution dataset to equation 2.179 using a Δx of 0.1 and 0.01 as compared to the analytical solution provided in equation 2.92.
Example: PDE - The Heat Equation

We will use this section as an opportunity to provide a numerical solution set to the 2D version of the heat equation (the heat equation is derived in section ?? as equation ??). For continuity, the 2D heat equation is provided here as equation 2.185.

cpρ𝑑𝑇 𝑑𝑡 = Kd2T dx2 + Kd2T dy2 (2.185)

For this example, we will assume that our 2D solid is a rectangle with a height of 50 and a width of 100. cp, ρ and K are constants that described in detail in section ??. In this example, these constants will be set to values as follows: cp = 1, ρ = 1, K = 5.

For our initial condition, we will assume that the entire solid is at a temperature of 100 at t = 0. This is shown in equation 2.186.

T(x,y,0) = 100 (2.186)

For our boundary conditions, we will assume that all edges have a temperature of 0 except for the right edge which is 200. This is shown in equation 2.187.

T(x,0,t) = 0 T(x,L,t) = 0 T(0,y,t) = 0 T(L,y,t) = 200 (2.187)

Now, it is time to apply a finite difference approximation to equation 2.185. In this example, we will use forward difference (equation 2.162) for the 𝑑𝑇 𝑑𝑡 term and second order central difference (equation 2.175) for the d2T dx2 and d2T dy2 terms. We will define our values at selected times tk, selected x locations xm, and selected y locations yn, where k,m,n are integer values. To express T at a given t,x,y in a concise fashion, we will shorten T(tk,xm,yn) to Tm,nk. Implementing this notation using our chosen finite different approximations, we get equation 2.188.

cpρTm.nk+1 Tm.nk Δt = KTm+1,nk 2Tm,nk + Tm1,nk Δx2 + KTm,n+1k 2Tm,nk + Tm,n1k Δy2 (2.188)

Solving for Tm.nk+1, we get equation 2.189.

Tm.nk+1 = KΔt cpρΔx2 (Tm+1,nk 2T m,nk + T m1,nk) + KΔt cpρΔy2 (Tm,n+1k 2T m,nk + T m,n1k) + T m,nk (2.189)

Now, from our initial condition we know all of the Tm,n0 points. Using equation 2.189, we can calculate all Tm,n1 points. In this way, we can calculate the next time step points Tm,nk+1 based on Tm,nk by iteration at each timestep k. This is best done in a coding software such as MATLAB or python. To provide the reader with a visualization of a solution to equation 2.185, equation 2.189 was input into a coding software to calculate temperature distribution of the rectangle for each time step. The result of numerical solution is shown in Figure 2.5 at select time steps 0, 20, 40, and 60. For the written code, increments were set as follows; 𝑑𝑥 = 𝑑𝑦 = 5, 𝑑𝑡 = .5051.

PIC

Figure 2.5: Numerically computed solution to equation 2.185 at time steps 0, 20, 40, and 60.