Electricity and Magnetism I (P331) M. R. Shepherd October 14, 2008 Differential Equations The purpose of this note is to provide some supplementary background on differential equations. The problems discussed below deal largely with those we have encountered in introductory mechanics. Hopefully a discussion of differential equations in the context of mechanical systems, where we are likely to have a more solid physical intuition, will let us focus on the math itself. Once we have a conceptual understanding of the mathematics then it may be useful to review the problems in the context of electrostatics as discussed in the text. There have been many textbooks written on both ordinary and partial differential equations most math students take a full year to study each topic. Therefore, it is impossible to teach the topic in just a few pages, but hopefully the notes below provide a brief introduction to a couple of elementary differential equations frequently encountered in physics and give some insight on the general technique for solving them. Ordinary Differential Equations A differential equation is an equation that describes how a function changes. In the case of a typical equation that most of us learned about in our first algebra class, we search for a single value that is the solution. For example the solution to x + 1 = 10 is x = 9. With differential equations, we are instead looking for a function that satisfies the equation instead of just a numerical value. When that function is a function of just one variable we say that the differential equation is an ordinary differential equation (ODE). Motion with constant acceleration Let s take a familiar example from mechanics. Suppose we have a object with constant acceleration a. We can write dv = a. (1) dt Here v is really v(t), a function of time. In this example a is a constant. The general solution to this equation is v(t) = at + C, (2) where C is an arbitrary constant. It turns out in the context of our physical problem at time t = 0 we have v(0) = C and therefore we associate C with the initial velocity v 0 and write v(t) = v 0 + at. (3) This equation above is also a differential equation that describes the rate of change of x(t). We have to which the general solution is dx dt = v 0 + at, (4) x(t) = v 0 t + 1 2 at2 + C. (5) Similar to above, when t = 0 we have x(0) = C and we associate C with x 0, the initial position of the object. These two equations may hardly seem like differential equations. They are quite easy to solve since there is no explicit dependence on the function that is being differentiated, i.e. dx/dt doesn t depend on x itself. The functions can be solved by multiplying through by dt and then integrating both sides. 1
Mass on a spring Let s now consider a slightly more complicated example from mechanics: the case of a mass on a spring. A mass on a spring obeys Hooke s Law so we can write the force on the mass as F = kx. (6) Using Newton s second law, we then have d 2 x dt 2 = k x. (7) m Unlike the simpler equations above, we now have have an equation that relates the second derivative of a function x(t) to the function itself. Physically this says that the acceleration of the mass depends on the position, and that makes sense since the more stretched the spring is, the larger the force and, therefore, the acceleration will be. What happens next may appear to be pulled out of thin air, but this happens all the time when solving differential equations. To find a solution we start with an ansatz. (Ansatz is a sophisticatedsounding German word that means a guess that is almost correct that we intend to patch up in the end to make it correct. ) So we start with the ansatz that x(t) = A sin(ωt + φ), (8) where ω, φ, and A are arbitrary constants. Plugging this ansatz back into our original equation gives d 2 dt (A sin(ωt + φ)) = k A sin(ωt + φ) m d dt (Aω cos(ωt + φ)) = k A sin(ωt + φ) m Aω 2 sin(ωt + φ) = k A sin(ωt + φ). m We see that our ansatz is correct if the arbitrary constant ω in our ansatz is equal to k/m. Note that the differential equation itself does not place any restrictions on A or φ. So, the general solution is x(t) = A sin( k/m t + φ). (9) In other words, all that we learn from the differential equation is that the mass is going to oscillate back and forth with an angular frequency of k/m. The amplitude of the oscillations A or the phase of the oscillations φ must be given by other boundary conditions. For example, we need to know the starting position and velocity of the mass. That would allow us to uniquely define A and φ and from there we would have a specific unique equation of motion for the system. We could have picked for the ansatz the cosine function instead of the sine. We would find that it would work also. In fact, a solution of the form x(t) = A sin( k/m t + φ) + B cos( k/m t + δ) (10) works just fine. (Try it if you don t believe it.) However, this can be rewritten as a single sine or cosine function, and, when the boundary conditions are enforced, will result in the exact same prediction for the motion. The structure of the function may not be unique, e.g. sin(θ) = cos(θ π/2), but the prediction for the motion of the object, that is, the value of the function at any time t, is unique. Two common equations In rectangular coordinates, two common differential equations that are encountered are d 2 x dt 2 = bx, and (11) d 2 x dt 2 = bx, (12) 2
where b is some positive constant. The solutions to the first we discussed in detail above. The general solution to the second is x(t) = Ae bt + Be bt (13) Here again, all we learn from the differential equation itself is the general form. We must use the boundary conditions of a specific problem to determine the constants A and B. Memorize these two general solutions and be on the lookout for them! Cool mathematical side note: These two systems of equations are not as different as they look. We can see the relationship with what is known in complex analysis as Euler s formula e iθ = cos θ + i sin θ, (14) where i = 1. Remember that the cosine is even while the sine is odd. Therefore we have: e iθ e iθ = (cos θ + i sin θ) (cos θ i sin θ) = 2i sin θ e iθ + e iθ = (cos θ + i sin θ) + (cos θ i sin θ) = 2 cos θ This means that we can construct cosine and sine functions from exponentials of imaginary numbers and vice versa. The connection can also be seen by noting that the solution x(t) = Ae i k/m t satisfies our differential equation for the harmonic oscillator since we have d 2 ( dt 2 Ae i ) ( k/m t = i 2 k/m) Ae i k/m t = k m x(t). This hints at a practical general method for solving differential equations: take an ansatz of the form x(t) = Ae γt, plug this ansatz into the equation, and solve for the values of γ. They may be purely real or complex. These then determine general solutions to the equation which are typically sums and products of exponentials, sines, and cosines. ODE Summary An ordinary differential equation describes how a function changes. Sometimes the equation can be solved by direct integration. Most frequently it is solved by guessing and then testing a general solution. One typically determines the form of the general solution first and then selects the arbitrary constants in the general solution to match the boundary conditions of a unique physical problem. Partial Differential Equations Up to now we have dealt with socalled ordinary differential equations (ODEs). These were equations that described the behavior of functions of single variable (which was time in the examples above). A partial differential equation (PDE) relates partial derivatives of a function of more than one variable. The solution to a PDE is a multivariable function. Again lets work with an example from mechanics: suppose that we have a string of length L that is fixed at both ends. Let s displace the string at the center a distance d from the equilibrium and release it. How do we determine the subsequent motion of the string? d u(x,t) 0 L x 3
Consider the wave equation in one dimension that describes vibrations of a string. Let s indicate the position along the string by the coordinate x. So, x = 0 is one end and x = L is the other end. Let u be the displacement of the string from its equilibrium position, which varies with x. The displacement is also timedependent so we have u is a function of x and t: u(x, t). Therefore at any place x between 0 and L and at any time t the function u(x, t) gives the displacement of the string from equilibrium. The wave equation (a PDE) states that 2 u x 2 1 2 u c 2 = 0. (15) t2 Here c is a constant which is equal to the linear speed of the wave, which, as you might remember, is related to the physical properties of the string. This equation describes how the displacement of the string changes for a fixed moment in time as one moves along the length of the string or for a fixed point on the string as time goes forward. Like we did with ordinary differential equations, we are interested in finding the general solutions of this equation. In order to solve this equation, we employ a technique known as separation of variables. We assume that our solution u(x, t) can be written as a product u(x, t) = X(x)T (t), where X and T are functions that depend only on x and t, respectively. Then plugging this back into the equation above we obtain T d2 X dx 2 X c 2 d 2 T dt 2 = 0, and dividing through by XT gives 1 d 2 X X dx 2 1 d 2 T T c 2 dt 2 = 0. Now, the first term in the expression depends only on X while the second depends only on T. The only way to generally satisfy this equation is to have both of the terms equal to the same constant. Let s call that constant b. Note that the original PDE says that the difference of the two terms is zero. This implies 1 d 2 X X dx 2 = b = d2 X dx 2 = bx 1 d 2 T T c 2 dt 2 = b = d2 T dt 2 = bc2 T We ve now separated the original PDE into two ordinary differential equations. These two equations are exactly the same as the ones we encountered earlier. Note that in this case b is an arbitrary constant and can be positive or negative, but it is the same for both differential equations. If b is positive, we know our solutions are going to be exponentials in time and position. If b is negative our solutions are going to be periodic (sines and cosines) in time and position. We now have to think a little about the physical problem to make the correct choice. Imagine a fixed point on the string, the motion of this point in time is periodic it goes back and forth about the equilibrium. This suggests that we want b < 0. To make this choice more explicit let s rewrite the equations setting b k 2, where k is an arbitrary constant. Now we have d 2 X dx 2 = k 2 X d 2 T dt 2 = k 2 c 2 T. We can immediately write down the general solutions to these equations you should recognize them from before: X(x) = A sin kx + B cos kx, T (t) = C sin kct + D cos kct. 4
This leads to the solution: u(x, t) = (A sin kx + B cos kx)(c sin kct + D cos kct) (16) What remains is to determine the constants A, B, C, D, and k to satisfy the boundary conditions of the problem. This task is not all the different, in principle, than determining that the constants in the solutions for constantacceleration motion are initial velocities and positions. In practice, it is a little more complicated. Let s write down all of the boundary conditions: 1. u(0, t) = 0 and u(l, t) = 0: the ends of the string are permanently fixed. 2. u/ t = 0 for all x at t = 0: the string starts at rest at t = 0 just as it as released. 3. u(x, 0) = 2dx/L for x L/2 and u(x, 0) = 2d(L x)/l for x > L/2: this equation defines the initial shape of the string. Since we want the point x = 0 to have u = 0 we can solve the first part of the first boundary condition by setting B = 0. Removing the cos kx terms guarantees that for x = 0 we get 0. We can solve the second part of the first boundary condition by picking k = nπ/l (n = 0, 1, 2,...). That way when x = L we get sin nπ, which is always zero. Therefore, after satisfying the first boundary condition, we are left with u(x, t) = A sin(nπx/l)(c sin(nπct/l) + D cos(nπct/l)). (17) To satisfy the second boundary condition we pick C = 0. Notice that u t = A sin(nπx/l)(c(nπc/l) cos(nπct/l) D(nπc/L) sin(nπct/l)). The only way to have u/ t = 0 for all x at t = 0 is to have C = 0. The constant D does not have to be zero since sin 0 = 0. We now have: u(x, t) = A sin(nπx/l)(d cos(nπct/l). (18) Now comes the most challenging boundary condition to satisfy. We need, at time t = 0, the equation u(x, t) to take the form 2dx/L for x L/2 and 2d(L x)/l for x > L/2. Clearly a single sine function alone does not satisfy this criterion. This is where the typical technique for solving PDEs starts to depart from that for ordinary differential equations. For the mass and spring problem we just needed to match our solution to a particular single value, for example x 0, at time t = 0. For the string we must match our solution onto a function that describes the initial displacement of the string. In order to satisfy this boundary condition we need to first make the observation that sums of functions of the general form of Eq. 18 with different constants A, n, or D are also solutions. Remember that our original PDE says that a difference of partial derivatives is zero. Since differentiation is distributive, e.g. (u 1 + u 2 )/ t = u 1 / t + u 2 / t, then the original PDE must hold for a sum of equations that each satisfy the PDE. Combining constants A and D and allowing u to be expressed as a general sum of solutions let s rewrite the general solution (Eq. 18) as u(x, t) = The final boundary condition states that u(x, 0) = C n sin(nπx/l) cos(nπct/l). (19) n=0 C n sin(nπx/l) = n=0 { 2dx/L if x L/2 2d(L x)/l if x > L/2 In other words, we need to pick a C n for each integer n so that the above equation is true. We know that there must be a solution since the set of sine and cosine functions are a complete set of functions, i.e. any (20) 5
other function whose domain is some finite interval can be written as sum of sines and cosines. The only chore is to determine what combinations of sin(nπx/l) with what strengths C n give exactly our boundary condition. We won t go through the details of the derivation here since they can be found on pg. 130 in your book (concluding with Eq. 3.34). The expression for each C n is given by C n = 2 L [ L/2 0 L 2d(L x) (2dx/L) sin(nπx/l)dx + sin(nπx/l)dx L/2 L ]. (21) Note that this is essentially the product of our boundary condition function and sin(nπx/l) integrated over the domain of the solution. Computing this integral gives the following expression C n = 32d cos(nπ/4) sin3 (nπ/4) n 2 π 2. Now, remember that n must be an integer. When n = 0, 4, 8,... the sin(nπ/4) in the numerator is zero. When n = 2, 6, 10,... the cos(nπ/4) in the numerator is zero. Recall that cos(π/4) = sin(π/4) = 1/ 2. Therefore writing out the product in the numerator for the first few odd n we have n = 1 cos(π/4) sin 3 (π/4) = 1 4, n = 3 cos(3π/4) sin 3 (3π/4) = 1 4, n = 5 cos(5π/4) sin 3 (5π/4) = 1 4, n = 7 cos(7π/4) sin 3 (7π/4) = 1 4. This gives us then the general pattern for the C n 0 n = 0, 2, 4,... C n = 8d/n 2 π n = 1, 5, 9,.... 8d/n 2 π n = 3, 7, 11,... We can cleverly recast this as an expression that is valid for all n C n = Now, substituting back into Eq. 20 we have u(x, 0) = ( 1)n 8d (2n + 1) 2, n = 0, 1, 2,... π2 n=0 ( 1) n 8d (2n + 1) 2 π 2 sin ( (2n + 1)πx L ). (22) In Figure 1 we plot the first 1, 2, 10, and 100 terms of this sum. With an infinite number of terms, we can satisfy the boundary condition exactly. With this choice of C n we are now able to match our general solution onto a specific function of x for the initial boundary condition. Remember this process was complicated by the fact that we had to get u(x, 0) correct for all x. After picking the C n to satisfy this final boundary condition, we can now write the solution: u(x, t) = 8d π 2 n=0 ( 1) n (2n + 1) 2 sin ( (2n + 1)πx L ) cos ( (2n + 1)πct L ). (23) The math ends here, but we can squeeze a little more physics out the problem by examining the solution. Consider the general characteristics. For a fixed instant in time the cosine term is constant, and the sum of 6
d = L = 1 0.2 0.4 0.6 0.8 first term 0.2 0.4 0.6 0.8 first 2 terms 0.2 0.4 0.6 0.8 first 10 terms 0.2 0.4 0.6 0.8 first 100 terms Figure 1: The first 1, 2, 10, and 100 terms of the Fourier series to describe the initial boundary condition of the plucked string. sines gives us the shape of the string. For a fixed position along the string the sine term is constant, and the point oscillates in time about the equilibrium according to the cosine term. We ve verified that the sine term, which carries the x dependence, along with the coefficients reproduces the initial conditions. The time dependence is carried in the cosine term. Note that the angular frequency of the oscillations for a point on the string is given by ω = (2n + 1)πc/L. For n = 0, the fundamental harmonic, we have λ = 2L. For n = 1, which corresponds to the third harmonic, the wavelength is 2 3 L. With n = 5, the fifth harmonic, λ = 2 5 L. In general the wavelength of the standing wave for each n is given by λ = 2L/(2n + 1). This gives then ω = 2πc/λ, but c/λ is just f remember the wavelength of a wave times its frequency gives the speed. So we have, for each harmonic, ω = 2πf, where f is what we expect from wave mechanics. We can also see that only those C n that correspond to odd harmonics of the fundamental mode of oscillation of the string are nonzero. This makes sense since the even harmonics have node at the center of the string (where we have initially displaced it). Plucking the string at this wouldbe node suppresses these harmonics. In the case of the string on a musical instrument, the C n can be viewed as the intensity of the higher harmonic overtones. These are what give character to the sound. If we were to pluck the string not at the center but closer to one end, then, in general, both even and odd harmonics are present and the C n that satisfy the initial boundary conditions do not die off as fast with increasing n. This explains how one gets a different tone out of a guitar depending on where along the string it is plucked. It also suggests that putting the hammers on the end of the piano strings (as they are in a piano) contributes to to the richness of the sound since hammering the string towards the end tends to excite the higher harmonics of the string. PDE Summary The general technique for solving PDEs is to first attempt to separate the dependence of the solution on each of the variables. This is done by writing the solution as a product of independent functions of one variable. The PDE can then typically be written as a sum of terms, each of which depend only on one variable. Each term is independently required to be constant, which then provides an ODE for each of the dependent variables. The general solutions to these ODEs are determined and then a product of these solutions determines the general form of the solution to the original PDE. Constants are chosen to satisfy the 7
boundary condition. Typically, at least one of the boundary conditions requires that one match an infinite sum of solutions (in the form of a Fourier series) onto a particular function. Additional Notes Connections to electrostatics The techniques discussed above are mathematically very similar to those used to solve problems in electrostatics. Here, instead of the wave equation, we are typically working with Laplace s Equation 2 V = 0. (24) This means that the dependent variables of the function V are x, y, and z. There is no time dependence as we had above; however, this change is purely a physical one the mathematics remains unchanged. While our boundary conditions in the example above was related to the configuration of the string at some initial time, the boundary conditions in solutions to Laplace s equation typically describe the potential at a particular place. Solutions to other common ODEs Above we noted the solution to two common ODEs encountered in rectangular coordinates. These solutions alone are enough to solve Laplace s equation for rectangular geometries. When working in spherical coordinates two other ODEs often appear after the separation of variables is performed: ( d r 2 dr ) = l(l + 1)R, and (25) d dθ dr dr ) ( sin θ dθ dθ = l(l + 1) sin θθ. (26) In this case, R(r) and Θ(θ). It is not necessary to know how to solve these equations, although you might be able to solve the first by just guessing the solution. When you come across them, just know that the solutions are R(r) = Ar l + B, and (27) rl+1 Θ(θ) = P l (cos θ), (28) where l is an integer and P l (cos θ) denotes the l th Legendre polynomial of cos θ. (You can find a table of the first five Legendre polynomials on pg. 138 of your book.) Again it is important to stress that the key thing is understanding that preforming a separation of variables of Laplace s equation in spherical coordinates yields these two ODEs and that the functions above are the solutions. We can the continue to construct a general function that is a product of R and Θ and use a sum of these solutions (if necessary) with appropriately chosen constants to satisfy the boundary conditions of the problem. 8