Alexander Fufaev
My name is Alexander FufaeV and here I write about:

Variation of Constants and How to Solve Inhomogeneous Differential Equations of 1st Order

DEQ types: Ordinary, first order, inhomogeneous
Variation of constants is suitable for ordinary 1st order inhomogeneous differential equations.

The method of variation of constants is well suited for:

  • ordinary DGL of first order

  • which are linear

  • and inhomogeneous.

The homogeneous DEQ is a special case of the inhomogeneous DEQ, therefore the variation of constants method is also suitable for homogeneous DEQ. You have this type of differential equation if you can put your differential equation into the following form:

The inhomogeneous version 1 differs from the homogeneous one only in the single coefficient, that is the perturbation function \(S(x)\) is not zero. Thus, this type of differential equation is somewhat more difficult to solve.

In this solving method, you make the ansatz that the general solution \(y(x)\) is given by a coefficient \(C(x)\) that depends on \(x\), multiplied by a homogeneous solution that we denote as \( y_{\text h}(x) \):

You have already learned how to find the homogeneous solution \( y_{\text h} \). All you have to do is to set the perturbation function to zero: \( S(x) = 0 \). Then you have the homogeneous differential equation. You solve it with separation of variables or directly by using the corresponding solution formula:

We insert this ansatz 2 into the inhomogeneous equation 1 for \(y\):

We also want to replace the derivative \(y'\) with our ansatz. To do this, we must first differentiate \(y\) with respect to \(x\). Since both \(C(x)\) and \( y_{\text h}(x) \) depend on \(x\), we need to apply the product rule. You do this by differentiating \(C(x)\) once, leaving \( y_{\text h} \), and then leaving \(C(x)\) and differentiate \( y_{\text h} \). The result is the derivative of our ansatz:

We insert the derivative \(y'\) into the general form of the differential equation 1:

If you just factor out \(C(x)\), you might see why this ansatz is so awesome:

The homogeneous differential equation is given in the parenthesis. Of course it is zero. This is the definition of a homogeneous DEQ. So we can omit this term completely:

You can now rearrange the equation for the unknown coefficient \(C'(x)\):

Now, to eliminate the derivative \(C'(x)\), we have to integrate both sides over \(x\). You know, the integration is the inverse, so to speak, of a derivative:

We cannot integrate the right side concretely, because\(S(x)\) is different depending on the problem. Therefore we leave the right side unchanged. The left side, on the other hand, can be integrated and additionally yields an integration constant, let's call it \( B \):

We bring it directly to the right side and define it for example as a constant \(A := -B\):

If you now just substitute the found coefficient \(C(x)\) into the original ansatz 2, then you get the general solution of an ordinary inhomogeneous linear differential equation of 1st order:

Example: Apply variation of constants to RL circuit

RL circuit - Switch-on process Hover the image!
A simple RL circuit.

Consider a circuit consisting of a coil characterized by the inductance \(L\) and a resistor \(R\) connected in series. Then we take a voltage source which provides a voltage \(U_0\) as soon as we close the circuit with a switch. Then a time dependent current \(I(t)\) flows through the coil and the resistor. The current does not have its maximum value immediately, but increases slowly due to Lenz law. Using Kirchoff's laws, we can set up the following differential equation for the current \(I\):

Remember that the point above the \(I\) means the first time derivative. This is an inhomogeneous linear differential equation of 1st order. You can see this best if you put this equation into a more familiar form 1. Divide both sides by \(L\). Thereby you eliminate the \(L\) in front of the derivative:

Bring the single coefficient to the other side:

And we already have the familiar form. The searched function \(y\) corresponds here to the current \(I\). The perturbation function \(S(t)\) corresponds to \(\frac{U_0}{L}\) and is time independent in this case: \( S = \frac{U_0}{L} \). The coefficient \(K(t)\) in front of the searched function \(I\) corresponds to \(\frac{R}{L}\) and is also time independent in this case: \(K = \frac{R}{L} \).

So far so good. Let's use the just derived solution formula 12 for the inhomogeneous differential equation of 1st order. We denote the homogeneous solution by \(I_{\text h}\):

First, we need to determine the homogeneous solution \(I_{\text h}\). We can quickly calculate this using the solution formula 3 for the homogeneous version of the differential equation:

We may omit the constant \(C\) in the solution formula here, because we consider it later anyway in the constant \(A\), which we find in the other solution formula 12.

The coefficient \(\frac{R}{L}\) is constant and integrating a constant only introduces a \(t\). Thus, the homogeneous solution is:

Let's insert it into the inhomogeneous solution formula:

Note that '1 over the exponential function' containing a minus in the exponent is simply equivalent to the exponential function without the minus sign.

Now we have to calculate the integral in 19. Here \(\frac{U_0}{L}\) is a constant and can be placed in front of the integral. And when integrating the exponential function, the exponential function is preserved. Only \(\frac{L}{R}\) is added as a factor in front of the exponential function. Finally we hide the constant of integration in the constant \(A\):

And we already have the general solution. We can simplify it a bit more by multiplying out the parentheses. Two exponential functions simplify to one:

To get a solution specific to the problem, we need to determine the unknown constant \(A\). For that we need an initial condition. If we say that the time \( t = 0 \) is the time when the current \(I\) was zero because we have not yet closed the switch, then our initial condition is: \( I(0) = 0 \). Insert it into the general solution:

and solve for \(A\):

Thus, we have successfully determined the specific general solution:

Now you know how to solve 1st order linear inhomogeneous differential equations. In the next lesson, we will look at how to handle even more complicated differential equations using the so-called exponential ansatz.