# Mathematics - Second-order Differential equation exercises Hello it's a me again drifter1! Today we will get into Mathematics again to do some 2nd-order ODE exercises. I will get into the different cases of problems that you can get and solve them step by step and very precisely, so that you understand my way of thinking.

So, without further do, let's get straight into it!

## Actually 1st-order case

When a 2nd-order ODE doesn't contain y = y(x) then we substitute u = y' and get a 1st-order ODE that will be of one of the types we discussed previously in my series.

Here you can find exercises for all the cases.

So, let's try solving one!

xy" + y' + x(y')^2 = 0 (non-linear second-order ODE)

We can clearly see that y = y(x) is missing and so we substitute using u = y'.

xu' + u + xu^2 = 0

Let's divide with x!=0 to find the type:

u' + (1/x)* u + u^2 = 0    [Bernoulli ODE]

Because it's a Bernoulli form we substitute z = u^(-1) = 1/u and so:

z' = (1/u)' = -(1/u^2)*u'.

Let's put u' from the Bernoulli equation:

z' = -(1/u^2)*[-(1/x)*u - u^2].

By changing 1/u with z we then get:

z' = -z^2*[-(1/x)*1/z - 1/z^2] =>

z' = 1 - z/x =>

z' - (1/x)*z = 1    [Linear ODE]

So, we again have to subsitute z = gZ to solve the linear one!

g = e^(-integral(Pdx)) = e^(-integral(-1/x)dx) = e^lnx = x

Z = integral(Q/g)dx=>

Z = integral(1/x)dx = lnx + c

And so z = x*lnx + xc.

That way:

u = 1/z = 1/(xlnx +xc)

y = integral(u) =>

y = integral[1/(xlnx + xc)]dx

Solving this integral we then get y, but this is not an easy case and needs some time!

I hope that you at least got an idea!

## Constant coefficient cases [ay" + by' + cy = R(x)]

There are many different cases that depend on the solutions p1, p2 of the characteristic equation and also the form that R(x) has!

Let's solve one of each! (I will leave out the complex R(x) case)

### 1) p1, p2 will be real and R(x) exponential

y" + 3y' + 2y = 2e^-x    [given ODE]

Let's write the homogeneous one:

y" + 3y' + 2y = 0

By substituting y = e^px we get the following:

p^2 + 3p + 2 = 0    [characteristic equation]

This one has the solutions:

p1, 2 = [-3 +- root(3^2 - 4*1*2)] / 2*1 =>

p1, 2 = -3 +- 1 / 2 =>

p1 = -1 and p2 = -2

That way y1 = e^(-x) and y2 = e^(-2x)

The general homogeneous solution (y0) is:

y0 = c1*e^(-x) + c2*e^(-2x), where c1, c2 reals

R(x) is exponential and k = -1

k = p1 = -1 and so we are in the 2nd case and yp is of the form:

yp = λ*x*e^(-x)

λ = ?

Let's first find the derivatives of yp and then put them in the given ODE.

y'p = [λ*x*e^(-x)]' = λ*[e^(-x) - x*e^(-x)] = λ*e^(-x)*(1-x)

y"p = { λ*e^(-x)*(1-x)}' = ... = λ*e^(-x) * (x-2)

By setting y, y' and y" to those in the given ODE we get:

λ*e^(-x) * (x-2) + 3*λ*e^(-x)*(1-x) + 2*λ*x*e^(-x) = 2e^(-x).

The e^(-x) parts are gone directly and so we get:

λ*(x-2) + 3*λ*(1-x) + 2*λ*x = 2 =>

-2λ + 3λ = 2 => λ = 2

And that way yp = 2*x*e^(-x)

The general solution is:

y = y0 + yp =>

y = c1*e^(-x) + c2*e^(-2x) + 2*x*e^(-x)

### 2) p will be a double solution and R(x) polynomial

y" - 2y' + y = 2x^2 - 3    [given ODE]

The corresponding homogeneous is:

y" - 2y' + y = 0

That way the characteristic equation is:

p^2 - 2p + 1 = 0 => (p-1)^2 = 0

And so we have one double solution p = 1.

The solutions are:

y1 = e^x and y2 = x*e^x

yo = c1*e^x + c2*xe^x, where c1, c2 reals

R(x) is of the polynomial and c!=0 and so we are in the first case and:

yp = bn*x^n + ... + b1*x + b0 =>

yp = ax^2 + bx + c    [2nd-order polynomial]

a, b, c = ?

Let's first find the derivatives:

yp' = 2ax + b

yp" = 2a

By substituting those in the given ODE we get:

(ax^2 + bx + c) -2*(2ax + b) + 2a = 2x^2 - 3.

Let's create a Ax^2 + Bx + C term on the left side:

ax^2 + (b - 4a)x + (c -2b + 2a) = 2x^2 -3

That way:

ax^2 = 2x^2 => a = 2

(b - 4a)x = 0x => b - 4a = 0 => b - 8 = 0 => b = 8

c - 2b + 2a = -3 => c -16 + 4 = -3 => c = 9

So, yp = 2x^2 + 8x - 9

The final solution is:

y = y0 + yp =>

y = c1*e^x + c2*xe^x + 2x^2 + 8x - 9

### 3) p1, p2 will be complex and R(x) trigonometric

y" + y = 3sin(2x)    [given ODE]

The homogeneous is:

y" + y = 0

and characteristic equations is:

p^2 + 1 = 0 => p = root(-1) => p = +-i     (complex number)

That way y1 = e^(ix) and y2 = e^(-ix)

Using Euler's equation [e^iφ = cosφ + i*sinφ] we end up with:

y1 = sinx and y2 = cosx

And so the general solution of the homogeneous is:

y0 = c1*sinx + c2*cosx, where c1, c2 are reals

R(x) is trigonometric and no solution is equal to it and so:

yp = s*cos(2x) + t*sin(2x)

yp' = -2s*sin(2x) + 2t*cos(2x)

yp" = -4s*cos(2x) - 4t*sin(2x)

(simple trigonometric loop derivation)

By substituting in the given ODE we get:

[-4s*cos(2x) - 4t*sin(2x)] + [s*cos(2x) + t*sin(2x)] = 3sin(2x) =>

-3s*cos(2x) - 3t*sin(2x) = 3sin(2x) =>

-3s = 0 => s = 0

and

-3t = 3 => t = -1

That way:

yp = -sin(2x)

And the general solution is:

y = yo + yp =>

y = c1*sinx + c2*cosx - sin(2x)

## Euler case [ax^2y" + bxy' + cy = R(x)]

A second-order ODE that has coefficients that look similar to a 2nd-order polynomial equation (ax^2 + bx + c) is called a Euler ODE.

To solve such a ODE, we substitute x= e^t and get a constant coefficient form.

Let's solve one!

x^2y" - 2xy' + 2y = x^3    [given Euler ODE]

We set x = e^t and get:

ayt" + (b-a)yt' + cyt = R1(t)   =>

y"(t) - 3y'(t) + 2y(t) =e^3t     [Const coefficient ODE]

The homogeneous form is:

y"(t) - 3y'(t) + 2y(t) = 0

The characteristic equation is:

p^2 - 3p + 2 = 0

The solutions are: p1 = 1 and p2 = 2 and so:

y1 = e^t and y2 = e^2t

yo = c1*e^t + c2*e^2t, where c1, c2 are reals

For R(t) we have a exponential form, where p1, p2 != k and so:

yp = λ*e^3t

The derivatives are:

yp' = 3λ*e^3t

yp" = 9λ*e^3t

By substituting it in the const coefficient ODE we get:

9λ*e^3t - 3*3λ*e^3t + 2*λ*e^3t  = e^3t =>

9λ - 9λ + 2λ = 1 => λ = 1/2

That way:

yp = 1/2 * e^3t

And the general solution is:

y = y0 + yp =>

y = c1*e^t + c2*e^2t + 1/2 * e^3t

By setting back x = e^t we get our final solution:

y = c1*x + c2*x^2 + 1/2 * x^3

## Wronsky case [unknown form, but one solution(p1) is known]

Supposing one solution is given or can be found easily by testing some simple values we can find the second solution easily by using:

y1: known solution => y2 = y1*integral[W/y1^2]dx

For example suppose we have:

xy" - (x+2)y' + (1+2/x)y = 0    [given homogeneous ODE]

We know that x is a solution and we just have to find one more [y = y0].

So, we find W and then the solution y2.

W = e^integral(P(x)dx) =>

W = e^integral(-(x+2)/x)dx => ... =>

W =  e^(-x - 2lnx) =>

W = e^(-x) * e^(-2lnx) =>

W = e^(-x) * e^[lnx^(-2)] =>

W = e^(-x) / x^2

That way y2 = y1*integral[W/y1^2]dx =>

y2 = x*integral[(e^(-x) / x^2)/x^2]dx =>

y2 = x*integral[e^(-x)/x^4]dx

Time-taking integral that when solved gives us the 2nd solution and so:

y = y0 = c1y1 + c2y2

## Lagrange Method (canonical form) case

There are two basic cases where we apply this method.

### 1) Unknown or complicated ODE form

Here we get the canonical form (Y" + AY = 0) and solve y = gY.

For example:

x^2y" + 4xy' + (2-x^2)y = 0    [given ODE]

We set y = gY and get:

Y" + AY = 0.

A = -1/2*P' - 1/4*P^2 + Q =>

A = -1/2*(4/x)' - 1/4*(4/x)^2 + (2/x^2 -1) => ... =>

A = -1

And so we have:

Y" - Y = 0    [const coeffcient form]

p^2 - 1 = 0 => p1 = 1 and p2 = -1 and so:

Y1 = e^x and Y2 = e^(-x)

which means that Y = c1*e^x + c2*e^(-x), where c1, c2 are reals.

g(x) = e^[-1/2*integral(P(x)dx)] =>

g(x) = e^[-1/2*integral(4/x)dx] =>

g(x) = e^[-2*integral(1/x)dx] = e^[-2*lnx] = e^ln(-x^2) = 1/x^2

That way our final general solution is:

y = g*Y =>

y =  c1*e^x / x^2 + c2*e^(-x) / x^2

### 2) R(x) of unknown form

Here we find the solution yp using y1, y2 and W.

Suppose we have:

y" + 2y' + y = e^(-x) / x^2    [given const coeffcient ODE]

The homogeneous is:

y" + 2y' + y = 0

And so the characteristic equation is:

p^2 + 2p + 1 = 0

Which has one double solution p = -1

That way y1 = e^(-x) and y2 = x*e^(-x)

And so y0 = c1*e^(x) + c2*x*e^(-x), where c1, c2 are reals

The problem comes when we get into R(x) to find yp.

It's of an unknown form and so we have to use the equation:

yp = y2*integral[R(x)y1/W]dx - y1*integral[R(x)y2/W]dx

The Wronsky determinant will give us:

W = ... = e^(2-x) != 0    (will not do it, cause it's difficult to stylize)

and so we have linear independent solutions.

That way:

yp =

x*e^(-x) * integral[(e^(-x)/x^2)*e^(-x) / e^(-2x)] -

e^(-x) * integral[(e^(-x)/x^2)*x*e^(-x) / e^(-2x)] =>

yp = x*e^(-x) * integral(1/x^2)dx - e^(-x) * integral(1/x)dx =>

yp = x*e^(-x) * (-1/x) - e^(-x) * lnx =>

yp = -e^(-x) * (1 + lnx)

That way our general solution is:

y = y0 + yp =>

y = c1*e^(x) + c2*x*e^(-x) -e^(-x) * (1 + lnx)

### Previous posts of the series:

Introduction -> Definition and Applications

First-order part(1) ->  Separable, homogeneous and exact 1st-order ODE's

First-order part(2) -> Linear, Bernoulli and Riccati first-order ODE's

First-order exercises -> Exercises for all the 1st-order ODE types

Second-order linear with const coeffs -> Constant coefficient linear 2nd-order ODE's

Special second-order forms -> Linear Euler ODE, Wronsky and Lagrange (Canonical) methods

And this is it for today's post and I hope that you enjoyed it!

Next time we will get into how we solve any ODE using the Laplace method!

Bye!

H2
H3
H4
3 columns
2 columns
1 column