Topic 4 Linear Second Order Differential Equations
4.1 The general solution of a linear equation
Consider the linear second order differential equation Let be a particular solution, and the general solution of the associated homogeneous equation Then the function is the general solution of the non-homogeneous equation .
The function can be written as , where and are linearly independent solutions of the associated homogeneous equation. To find and , we can use dsolve
with the option output=basis
.
Example 4.1 Find two linearly independent solutions of the equation
Solution. We first run commands which provide better display.
PDETools[declare](y(x), prime=x): # Turn ON the enhanced DEdisplay feature
infolevel[dsolve] := 3: # Show more detailed information about computation
Now define the equation
ode31:=diff(y(x), x$2)+y(x)=0 # here x$n = x, x, ..., x, n copies of x
To find the independent solutions, run the following command
dsolve(ode31, y(x), output=basis)
The output is which means that and are linearly independent solutions.
If the homogeneous linear equation has constant coefficients, then one can also use
DETools[constcoeffsols]
to find a list of independent solutions.
Exercise 4.1 Find two linearly independent solutions of the equation
To find a particular solution of a nonlinear ODE, or a linear non-homogeneous ODE, one can use the command particularsol(ODE, dependent variable)
.
Example 4.2 Find a particular solution to the equation
Solution. First define the equation
ode32:=diff(y(x), x, x)-3*diff(y(x), x)+2*y(x)=2
To find a particular solution, we can use
with(DETools):
particularsol(ode32, y(x));
or
DETools[particularsol](ode32, y(x))
Exercise 4.2 Find a particular solution to the equation
4.2 Wronskian of Solutions
The Wronskian of two solutions and of a linear homogeneous second order differential equation is defined by
. In Maple, one can use the command Wronskian([y_1, y_2], independent variable, determinant=true)
or LinearAlgebra[Determinant](Wronskian([y_1, y_2], independent variable)
to find the Wronskian.
Example 4.3 The equation has two solutions and . Find the Wronskian and determine if the two solutions are linearly independent.
Solution. We first load the package VectorCalculus
.
with(VectorCalculus):
Now we calculate the Wronskian.
LinearAlgebra[Determinant](Wronskian([x, x^(-3)], x))
The output is
Because the Wronskian is not identically zero, the solutions are linearly independent.
Exercise 4.3 The equation has two solutions and . Find the Wronskian and determine if the two solutions are linearly independent.
4.3 Linear Equations with Constant Coefficients
When solving linear equations with constant coefficients, we need to solve equations and system of equations. That can be done by the Maple command solve({equations}, {unknowns})
. Moreover, one can add constrains by using assuming
together with solve
.
Example 4.4 Solve the initial value problem
Solution. Since this equation is a linear second order equation with constant coefficient, the solution is determined by the roots of the characteristic equation . Running the following Maple command will give us the roots.
rts:=solve(r^2-2*r-3=0, r);
The roots are
Since the root are real numbers, the general solution of the differential equation is
yh(x):=c1*exp(rts[1]*x)+c2*exp(rts[2]*x);
The initial conditions impose two equations for the constants c1
and c2
. We can calculate using D(y)
and solve the constants by the following command
consts:=solve({yh(0)=1, D(yh)(0)=-1}, {c1,c2});
The output is
So the solution to the initial value problem is which can be seen by the maple commands
y(x):=subs(consts, yh(x));
y(x);
Here, we take the approach of solving the problem manually. In Maple, we can use dsolve
or constcoeffsols
to solve differential equations with constant coefficients.
Exercise 4.4 Solve the initial value problem
4.4 Undetermined Coefficients
For some equations that can be written into the form , a particular solution can be found using the method of undetermined coefficients. Calculations can be made easy using Maple.
Example 4.5 Find a particular solution of
Solution. Since the right hand side is an exponential function, and 2 is a root of the characteristic polynomial of the complementary equation, we expect a specific solution . We then plug it into the equation to solve for .
Define the differential equation and the solution function.
ode341:=diff(y(x), x, x)-5*diff(y(x), x)+6*y(x)=3*exp(2*x);
yp(x):=A*x*exp(2*x);
Plugging into the differential equation and solve for A. Since is a number such that the equation is true for any . We use the solve/identity
method. The command runs like solve(identity(equation, x), vars)
.
eqnA:=subs[eval](y(x)=yp(x), ode341);
A=solve(identity(eqnA, x), A);
The output is
Instead of using the solve/identity
scheme, one can also build systems of equations for the undetermined coefficients manually.
When involves a polynomial, we want to get a system of undetermined coefficients. One way is to substitute by some general numbers. Another way is to differentiate both sides and then plug in . Once we get a system of the unknowns, we can solve it by the Maple command solve({eq1, eq2, ...}, {unknown1, unknown2, ...})
.
When involves sine or cosine, surely, we can plug in some general values for to obtain a system. We may also substitute by and to get two equations. From those two equations, we can build a system.
Example 4.6 Find a particular solution of
Solution. We expect a specific solution of the same type as the right hand side. Let’s try . We then plug it into the equation to solve for , , , and .
Define the differential equation and the solution function.
ode342:=diff(y(x), x, x)-2*diff(y(x), x)-3*y(x)=x*sin(x);
yp(x):=(a*x+b)*cos(x)+(c*x+d)*sin(x);
Plugging into the differential equation and solve for A.
eqnB:=subs[eval](y(x)=yp(x), ode342);
Now let’s deduce a system of equations for , , and .
# get an equation from coefficients of cosine
CoefCosine := subs([sin(x) = 0, cos(x) = 1], eqnB);
# get an equation from coefficients of sine
CoefSine := subs([sin(x) = 1, cos(x) = 0], eqnB);
# Get four equations for a, b, c, and d
eq1 := subs(x = 0, CoefCosine):
eq2 := subs(x = 0, CoefSine):
eq3 := diff(CoefCosine, x):
eq4 := diff(CoefSine, x):
Now we solve the equations as a system.
abcd:=solve({eq1, eq2, eq3, eq4},{a, b, c, d});
The output is
Let’s verify that the solution.
Sol:=subs(abcd, yp(x)) # plug a, b, c, d in yp(x)
odetest(Sol, ode342)
If is a polynomial, one can also use the command polysol
to find a polynomial solution.
Exercise 4.5 Find a particular solution of
4.5 Reduction of Order
Given a solution of a linear second order differential equation , one can use the trick of variation of parameter to find another solution in the form , here satisfies a second order equation in the form . This equation can be solve by reduction of order using the substitution . Indeed, we can expect .
In Maple, one can use the command reduce_order(ode, y(x)=y_1(x), u(t))
to obtain a lower order equation for . This command again belongs to the package DETools
.
Example 4.7 The equation has a solution . Find another linearly independent solution .
Solution. Let’s load packages first. Since with
can only load one package each time, let’s use a for
loop to load packages. To make the display looks better, let’s also run the declare
command.
for i in [DETools, LinearAlgebra, PDETools] do with(i) end do:
declare(y(x), prime=x):
Define the equation
ode35:=x^2*diff(y(x), x, x)+4*x*diff(y(x),x)-4*y=0;
Find the equation that u
satisfies.
RdOrder:=reduce_order(ode35, y(x) = x, u(t));
The output is
You can see that the equation for is , where is .
We can solve for and then find . Here, we use the operand extract command op
to get the differential equation for . The equation is the first element in the first list of the second vector of the right hand side of the output. We now get the equation for .
odeu:=subs(t=x, op([2, 1, 1], rhs(RdOrder)));
Now we substitute by and solve for and .
ux:=dsolve(odeu, u(x));
v:=int(ux, x);
Therefore, by the following command, we know that .
y[2](x):=x*v(x);
Testing using the following command shows that it is a solution.
odetest(y(x)=y[2](x), ode35);
To get the second solution after obtained the differential equation for , one can also use the command
buildsol(Reduced_Order_Equation, Particular_Solution_of_u)
One can also find without using
DETools
(see for example the Maple document on Linear Equations created by Prof. Douglas B. Meade.)
Exercise 4.6 The equation has a solution . Find another linearly independent solution .
4.6 Variation of Parameters
Maple has the command varparam(Solutions, f(x), x)
to find the general solution of a linear ODE by the method of variation of parameters, where is the right-hand side function. Again this command belongs to DETools
.
Example 4.8 Find the generals solution for the equation using the solutions and of the complementary equation
Solution. We can find the general solution using one line of command.
DETools[varparam]([x, 1/x^4], x, x)
The output is
Exercise 4.7 Find the generals solution for the equation using the solutions and of the complementary equation