Ordinary Differential Equations


Ordinary Differential Equations

Corey
Welcome back to Math for Electronics. This episode focuses on ordinary differential equations, or ODEs. The main goals are to understand what a differential equation is, recognize first-order linear equations, and introduce second-order homogeneous equations with constant coefficients.

Simon
And this is especially useful for electronics because differential equations describe how quantities such as current, voltage, velocity, and position change over time. In this course, the main emphasis is on first-order ODEs and second-order homogeneous ODEs with constant coefficients. Higher-order equations become important in later courses.

Corey
So what exactly is a differential equation? Suppose we have an unknown function f. A differential equation is an equation involving that function together with one or more of its derivatives. It might contain f of x, its first derivative f prime of x, its second derivative f double prime of x, and possibly even higher derivatives, along with other known functions of x.

Simon
The equation must be satisfied for the applicable values of x. For example, f prime of x equals 4 is a differential equation because it contains the first derivative of f. Likewise, f prime of x plus f of x equals 2 is also a differential equation.

Corey
The order of a differential equation is determined by its highest derivative, not by the order in which terms are written. So both of those examples are first-order equations because the highest derivative present is f prime. If an equation contains f double prime of x, f prime of x, f of x, and perhaps sine x, then it is a second-order ODE because the highest derivative is the second derivative.

Simon
That distinction matters. The word order here does not mean a sequence of terms; it tells us the highest derivative that appears. A first-order equation has no derivatives higher than the first, while a second-order equation may include first and second derivatives, but not necessarily higher ones.

Corey
Differential equations arise naturally in physical situations. Consider an apple falling through air. Let x of t represent its position at time t, and let v of t represent its velocity. The connection between position and velocity is v of t equals dx by dt, or equivalently, v of t is the first derivative of x.

Simon
The derivative of velocity is acceleration, so v prime of t represents acceleration. If the apple is falling downward, its weight, m g, acts downward, while air resistance opposes the motion. If the resistance is proportional to velocity, its magnitude is k v of t.

Corey
Taking downward as the positive direction, the total force is m g minus k v of t. Newton's second law says total force equals mass times acceleration, so m v prime of t equals m g minus k v of t. Dividing by m and rearranging gives v prime of t plus k over m times v of t equals g.

Simon
That is a first-order linear ODE for velocity. The initial condition is v of 0 equals 0 because the apple starts from rest. Initial conditions describe what is known before the process begins, and we use them later to determine the unknown constant in the solution.

Corey
If the object is thrown upward instead, both gravity and air resistance act downward, because air resistance always opposes the direction of motion. The signs in the force equation therefore change according to the chosen positive direction. The important modeling step is to identify the forces and then apply Newton's law consistently.

Simon
A second application is an RC circuit connected to a constant five-volt source. Kirchhoff's voltage law says that the voltage across the resistor plus the voltage across the capacitor equals 5 volts. For the resistor, the voltage is R times i of t, where i of t is the current.

Corey
For the capacitor, the current-voltage relationship is i of t equals C times the derivative of the capacitor voltage. Differentiating the voltage equation gives v R prime of t plus v C prime of t equals zero. Using v R prime equal to R i prime and v C prime equal to i over C produces R i prime of t plus one over C times i of t equals zero.

Simon
After dividing by R, the equation becomes i prime of t plus one over R C times i of t equals zero. Initially, the current is determined by the resistor, so i of 0 equals 5 over R. Solving the ODE gives the time-dependent current.

Corey
These examples lead to the general first-order linear ODE. It has the form f prime of x plus p of x times f of x equals q of x. The functions p of x and q of x are known, while f of x is the unknown function we want to find.

Simon
The falling-object equation fits this form with p of t equal to k over m and q of t equal to g. The RC equation fits it with p of t equal to one over R C and q of t equal to zero. The symbol x in the general formula is just a variable; in applications it might be replaced by time t.

Corey
A linear differential equation is one in which the unknown function and its derivatives appear only to the first power. Expressions such as f of x squared, f prime of x squared, or products like f of t times f of t would make an equation nonlinear. The focus here is primarily on linear ODEs.

Simon
Let's begin with the easiest first-order case: p of x equals zero. Then the equation is simply f prime of x equals q of x. Integrating both sides gives f of x equal to an antiderivative of q of x plus an arbitrary constant.

Corey
For example, if f prime of t equals sine of omega naught t, then integrating gives f of t equal to negative cosine of omega naught t divided by omega naught, plus a constant. The constant is not determined until an initial condition is supplied.

Simon
An initial condition makes the solution specific. We substitute the known value, such as f of zero, into the general solution, solve for the constant, and then write the particular solution.

Corey
The next important case is when p of x is a constant, which we can call p. The equation is f prime of x plus p f of x equals q of x. To turn this into the easy integration case, multiply every term by e to the power p x.

Simon
After multiplication, the left side becomes e to the p x times f prime of x plus p e to the p x times f of x. By the product rule, that is the derivative of e to the p x times f of x. So the equation becomes the derivative of e to the p x f of x equals e to the p x q of x.

Corey
Integrating gives e to the p x times f of x equal to the antiderivative of e to the p x q of x, plus a constant. Dividing by e to the p x produces f of x equal to e to the negative p x times that antiderivative, plus the constant multiplied by e to the negative p x.

Simon
This multiplying function, e to the p x, is the integrating factor for the constant-coefficient first-order equation. The exponential can never be zero, which is why dividing by it is valid. Once the formula is obtained, the remaining constant is found using the initial condition.

Corey
Apply that method to the falling apple equation, v prime of t plus k over m times v of t equals g. Here p is k over m and q is g. The solution becomes v of t equals m g over k plus C e to the negative k t over m.

Simon
Using v of zero equals zero gives C equal to negative m g over k. Therefore, v of t equals m g over k multiplied by one minus e to the negative k t over m. This starts at zero and increases as time passes.

Corey
The velocity does not increase without limit. As t becomes very large, the exponential term approaches zero, so the velocity approaches m g over k. That limiting value is the terminal velocity predicted by this model.

Simon
The time scale m over k is important. After one such time interval, the velocity reaches about 63 percent of its final value. After two intervals it reaches about 86 percent, and after three it reaches about 95 percent. The curve rises quickly at first and then gradually approaches m g over k.

Corey
For the RC circuit, the equation is i prime of t plus one over R C times i of t equals zero. Since q of t is zero, the integral term vanishes, leaving i of t equal to C times e to the negative t over R C.

Simon
The initial condition i of zero equals 5 over R makes the constant equal to 5 over R. Thus the current is i of t equals 5 over R multiplied by e to the negative t over R C. The current begins at 5 over R and decays exponentially toward zero.

Corey
Here, R C is called the time constant. After one time constant, the current is about 37 percent of its initial value, meaning it has dropped by about 63 percent. After three time constants, it is down to about 5 percent of its initial value, and as time approaches infinity, the current approaches zero.

Simon
Now let's move to second-order linear ODEs with constant coefficients. An RLC circuit provides a useful example because it contains a resistor, an inductor, and a capacitor connected in series. Kirchhoff's voltage law says that the sum of the component voltages equals the source voltage.

Corey
For the resistor, v R of t equals R i of t. For the inductor, v L of t equals L i prime of t. For the capacitor, i of t equals C v C prime of t. Differentiating the circuit equation and substituting these relationships gives L i double prime of t plus R i prime of t plus one over C times i of t equals the derivative of the source voltage.

Simon
This is a second-order linear ODE with constant coefficients because the coefficients L, R, and one over C are constants. In general, it can be written as A f double prime of x plus B f prime of x plus C f of x equals some function of x.

Corey
The homogeneous case is the especially important one in this course. Homogeneous means the right-hand side is zero, so the equation becomes A f double prime of x plus B f prime of x plus C f of x equals zero.

Simon
To solve it, we make an exponential guess: f of x equals e to the s x, where s is an unknown number. Then f prime is s e to the s x, and f double prime is s squared e to the s x.

Corey
Substituting those expressions into the differential equation and factoring out e to the s x gives e to the s x multiplied by A s squared plus B s plus C equals zero. Since an exponential is never zero, we solve the auxiliary, or characteristic, equation A s squared plus B s plus C equals zero.

Simon
The quadratic equation can produce three types of roots: two distinct real roots, one repeated real root, or complex roots. In this episode, the distinct real-root case is the one we develop fully; the repeated and complex cases require their own solution forms.

Corey
If the roots are distinct real numbers s one and s two, then e to the s one x and e to the s two x are both solutions. Any linear combination is also a solution, so the general solution is f of x equals C one e to the s one x plus C two e to the s two x.

Simon
The two constants are determined from two initial conditions, typically a value for f and a value for f prime. That is exactly what we expect for a second-order equation: two independent initial conditions are needed.

Corey
Consider f double prime of x minus 6 f prime of x plus 8 f of x equals zero, with f of zero equal to 1 and f prime of zero equal to 1. The auxiliary equation is s squared minus 6s plus 8 equals zero, which factors to give the distinct roots s equals 2 and s equals 4.

Simon
Therefore the general solution is f of x equals C one e to the 2x plus C two e to the 4x. Substituting x equals zero into f gives C one plus C two equals 1. Differentiating gives f prime of x equals 2 C one e to the 2x plus 4 C two e to the 4x, and substituting x equals zero gives 2 C one plus 4 C two equals 1.

Corey
Solving those two linear equations gives C one equal to 3 over 2 and C two equal to negative 1 over 2. The particular solution is therefore f of x equals 3 over 2 e to the 2x minus 1 over 2 e to the 4x.

Simon
A useful exam habit is to validate the result when time allows. Differentiate the proposed solution once and twice, substitute all three expressions back into the original differential equation, and check the initial conditions. This can catch errors in solving the quadratic equation or in finding the constants.

Corey
So the essential workflow is clear. First identify the order and whether the equation is linear. For a first-order linear equation, use direct integration when p is zero, or multiply by the integrating factor when p is constant. For a second-order homogeneous equation with constant coefficients, assume an exponential solution, form the auxiliary quadratic equation, classify its roots, and use the initial conditions to determine the constants.

Simon
And the applications tie the mathematics together: falling objects lead to velocity equations with a terminal value, RC circuits lead to exponential current decay, and RLC circuits lead to second-order equations. The repeated-root, complex-root, and nonhomogeneous cases are additional topics, but the central focus here is mastering first-order linear equations and homogeneous second-order equations with constant coefficients.

Ask anything
We've read this whole study set, so questions about it get the best answers.