Knowledge Node - Second Order Differential Equations

return to Knowledge Node index

Second-Order Differential Equations are all about equations that are based off of their rate of change, and their rate of the rate of change.  Sound confusing?  While second-order DE's can be applied to electronics, physics, and many other fields of engineering, one popular example of a second order DE is the Spring-Mass system.

Suppose we have a spring as pictured below.  The top of the spring is firmly attached to the ceiling   The bottom is attached to a small weight.  The spring stretches to accommodate the weight, and equilibrium position is defined as the position where the mass is at rest.  We want to create an equation that describes where the mass is at any time.

First, some theory behind the derivation of the following formulas.  There are several forces acting on the mass.

  1. The primary force to factor is the mass's own acceleration.  The universal physics law, force is equal to mass times acceleration, F=ma.
  2. Second, whenever the mass moves there is friction within the spring, in the air, plus any other dampening affect.  The faster the mass moves the more the dampening is in effect.  (When a car is not moving, there's no dampening in its motion, but when you're cruising down the highway at 60 MPH, you can hear the roar of the wind against the car, slowing it down)
  3. Thirdly, a force is generated by the spring itself whenever it is stretched out of position.  The further the spring is stretched, the more recovery force tries to pull the spring back towards it's equilibrium position.

Everything in the above equation should make sense, except the = 0.  That is the forcing function, the extra stuff that's pushing on the mass.  If the wind is blowing or there's an earthquake at a certain frequency, that sort of thing goes there.

If we recall from simple Calculus and Physics, we know that the velocity, the rate of change of position, is the same as the derivative of position.  Likewise, the acceleration is the derivative of velocity, or the derivative of the derivative of position (2nd derivative of position).

Since the objective is to describe the position (we'll call it x) of the mass at any moment (t, for time), we can write the equation for a mass's position as follows (m is mass, c is the dampening coefficient, and k is the spring constant).

Enough with the theory! Here's a concrete example.  Below is a spring-mass system where the mass has a weight of 1 unit, the dampening coefficient is 3/10, and the spring constant is 1.  Also, the spring is getting shaken with an oscillating force equal to sin(2*t).  Meanwhile, I decided to have a second forcing function that has a very small coefficient, meaning it will have very little effect in the beginning, but will greatly affect the position of the spring later on (imagine it as some unrealistic rocket engine that increasingly gets stronger over time).  Yeah, so I don't do anything simple, go figure.

To solve this second-order DE, first we solve for the homogenous part of the solution. 

Then we treat the derivatives as powers, and create the characteristic as follows.  The second derivative part is the r^2, the first derivative part is the r, the normal is the r^0.  The characteristic equation dramatically simplifies the process of solving the DE.

To solve the two solutions for r, use the quadratic equation that you learned in Algebra 1.

The equation has a real and imaginary result!

Our format for the homogenous solution is as follows.

All we do is substitute the two solutions we found for r, into the c and d constants.

"When you multiply like bases, you add the exponents."  Using this rule, we can separate the real and imaginary parts of the e terms.

Using Euler's identity, we can expand the imaginary exponents out into the following forms...

... and then group the cosine and sine terms.

See the constants?  Since we don't know what either of the constants are, we can simply assume that an unknown constant plus a second unknown constant, is a single unknown constant.  The imaginary number I gets absorbed into the constant, and we can replace the alpha's and beta's with a single theta and phi.

The solution to our equation is the homogenous plus the particular.

Since the homogenous solution is equal to zero in the end, we are going to replace it with a guess for the particular solution.

So all we have left is the sin(2*t)+0.0001*t^3.  We need to formulate a guess for our particular solution, that will encapsulate these two forcing functions.  Note that whenever there is a sin() or a cos() term, you must have both the sin() and cos() terms in the guess.  Whenever an nth-order polynomial is present in the forcing function, you must have (n-1)th, (n-2)th, etc present as well.

Since we are going to substitute our guess into the homogenous solution, which requires both a first and second order derivative of x(t), it is necessary to calculate these derivatives.  Here is the first derivative...

And the second...

If we substitute these guesses into our original equation, we get this massive beast below.

We have a problem!  We have 6 unknowns and only 1 equation.  Ah, but we can get 6 equations by grouping like coefficients.  If we take all the cosine terms on the left and set them equal to all the cosine terms on the right, we have one equation.  We can do the same for all the sine and the polynomial terms.  This is done as follows.

Since we don't need the cosine terms, sine terms, and polynomials, we just divide them out.  Now we have 6 equations and 6 unknowns!

Notice that this one is rather easy to solve by hand.  We get a variable for free!  Working our way up, we can plug in the known value for F into the 2nd from the bottom equation to easily calculate E.  The same can be done for D, then C respectively.  The top two equations can be solved using substitution, algebraic addition, or any number of ways.  Below are the values for all the constants.

If we plug all these constants back into our guess, we have our final particular solution!

Now if we add the homogenous and the particular back together, we have the final solution to our problem.

The only thing we don't know are the values for theta and phi.  Luckily we still have two pieces of information.  The initial conditions of the spring!  I'm going to have my spring start 6 units above it's equilibrium position, and no initial velocity.  This will simulate the spring being pulled out of equilibrium position, then let go.  This is the crucial step where we can change any aspect of our spring's initial motion.

This is one massive equation, the derivative of the solution.  This is needed as the second equation, since we can plug in the initial velocity (0) into it.

Below are the final two equations and two unknowns needed to solve the last unknown constants.  We substitute our values for the initial position (x=6), at the initial time (t=0), and the initial velocity (dx/dt=0)

All those cos(0) and sin(0) and e^0 simplify to really nice, basic numbers.  We can calculate theta almost for free in the first equation.  We can then substitute that value into the second equation to calculate phi.

Now that we have our final values for theta and phi...

... we can plug them into the final solution to get our finished position equation!

Below is the plot of our final equation.  Notice that it starts at 6, is released and quickly shoots towards equilibrium.  Like most springs, it overshoots.  Notice that it only dips down to -4.  This is due to dampening forces as well as the oscillating sin() force.  After overshooting, the spring bounces back and heads upward, only making it to a fraction of it's original height (slightly above 2).  It tips back down and comes up again, again much smaller.  Then suddenly, instead of shooting downward a third time it wobbles.  This is due to the oscillating sin(2*t) force beginning to overpower the initial motion of the spring.  Dampening quickly eats up the last of the moment of the initial release, and the spring settles into a steady sin(2*t) oscillation. 

Over a significant amount of time, the 0.0001*t^3 forcing function comes into effect.  While its effects can be seen in the above graph as the spring begins to rise, it is much more clearly evident over a longer period of time.

There we have it! A mathematical construct which approximates the position of a spring over time.  Manipulating the spring constants m, c, and k will cause various affects.  Dramatically increasing dampening can cause the spring to be over-damped or even critically-damped.  Different forcing functions will affect the spring in interesting ways.  It's important to note that unless the initial conditions match the forcing function, the original oscillations will eventually die out. 

Another thing to try is to remove dampening completely.  The b term in the quadratic equation will be zero, meaning only an imaginary solution to the equation will exist.  The e terms in the final equation will disappear, and it will be purely sine's and cosine's.

Once again, springs are just one application to the vast field of second-order differential equations.  I'm pretty sure they can also be used to approximate the charge in a capacitor-resistor-inductor circuit.  One can also derive a method to solve the position of a pendulum at any given time, although such an approximation is only good for small angles (I believe less than 15 degrees).

just curious... added 5/4/04

Some interesting references:

return to Knowledge Node index


return to the main page