online advertising

Friday, January 1, 2016

The method of variation of parameter (I)

Problem:

$ y'' - 2y = x + 1 $.

Solution:

Let's discuss the method in general first, consider the differential equation:

$ y'' + p(x)y' + q(x)y = r(x) $.

Assume we can solve the homogeneous equation

$ w'' + p(x)w' + q(x)w = 0 $

and get the solution the two independent solutions $ w(x) = w_1(x) $ and $ w(x) = w_2(x) $.

Now we assume the solution to the original equation takes the form:

$ y(x) = v_1(x)w_1(x) + v_2(x)w_2(x) $.

Computing the first derivative, we get:

$ y'(x) = v_1'(x)w_1(x) + v_1(x)w_1'(x) + v_2'(x)w_2(x) + v_2(x)w_2'(x) $.

As a wishful thinking, let's assume $ v_1'(x)w_1(x) + v_2'(x)w_2(x) = 0 $. This is one of the equation that govern $ v_1'(x) $ and $ v_2'(x) $.

Next, we compute the second derivative, we get:

$ y'(x) = v_1(x)w_1'(x) + v_2(x)w_2'(x) $.
$ y''(x) = v_1'(x)w_1'(x) + v_1(x)w_1''(x) + v_2'(x)w_2'(x)  + v_2(x)w_2''(x) $.

Putting these derivative back to the differential equation, we get:

$ (v_1'(x)w_1'(x) + v_1(x)w_1''(x) + v_2'(x)w_2'(x)  + v_2(x)w_2''(x)) + p(x)(v_1(x)w_1'(x) + v_2(x)w_2'(x)) + q(x)(v_1(x)w_1(x) + v_2(x)w_2(x)) = r(x) $.

A very long equation, but if we carefully group the terms we see this:

$ v_1'(x)w_1'(x) + v_2'(x)w_2'(x) + (v_1(x)w_1''(x) + p(x)v_1(x)w_1'(x) + q(x)v_1(x)w_1(x)) + (v_2(x)w_2''(x) + p(x)v_2(x)w_2'(x) + q(x)v_2(x)w_2(x)) = r(x) $.

Note that the two bracketed term is actually 0 because $ w_1(x) $ and $ w_2(x) $ is a solution to the homogeneous equation. So it simplifies to

$ v_1'(x)w_1'(x) + v_2'(x)w_2'(x) = r(x) $.

That will be our second equation that govern $ v_1'(x) $ and $ v_2'(x) $, with this two equations, we can solve the $ v_1(x) $ and $ v_2(x) $ and therefore the overall differential equation.

So much for the theory, now we solve the equation $ y'' - 2y = x + 1 $.

The homogeneous equation $ w'' - 2w = 0 $ is pretty easy to solve, it is simply $ w_1(x) = e^{\sqrt{2}x} $ and $ w_2(x) = e^{-\sqrt{2}x} $.

Next, we use the two equations to solve for the $ v $ functions

$ v_1'(x)e^{\sqrt{2}x} + v_2'(x)e^{-\sqrt{2}x} = 0 $
$ \sqrt{2}v_1'(x)e^{\sqrt{2}x} + (-\sqrt{2})v_2'(x)e^{-\sqrt{2}x} = x+1 $

Cancelling the $ \sqrt{2} $ factor from the second equation we get

$ v_1'(x)e^{\sqrt{2}x} - v_2'(x)e^{-\sqrt{2}x} = \frac{x + 1}{\sqrt{2}} $

Now the functions are trivial to solve $ v_1'(x) = \frac{x+1}{2\sqrt{2}}e^{-\sqrt{2}x} $, $ v_2'(x) = \frac{-x-1}{2\sqrt{2}}e^{\sqrt{2}x} $.

Next we integrate to find $ v_1(x) $ and $ v_2(x) $.

$ v_1(x) = \frac{-1}{8}(2x + \sqrt{2} + 2) e^{-\sqrt{2}x} $
$ v_2(x) = \frac{-1}{8}(2x - \sqrt{2} + 2) e^{\sqrt{2}x} $

Putting these back to the differential equation, we finally get

$ y(x) = v_1(x)w_1(x) + v_2(x)w_2(x) = \frac{-1}{8}(2x + \sqrt{2} + 2) +  \frac{-1}{8}(2x - \sqrt{2} + 2) = \frac{-1}{2}(x + 1) $.

And the final answer is, of course, $ y(x) = \frac{-1}{2}(x + 1) + Ae^{\sqrt{2}x} + Be^{-\sqrt{2}x} $.

To be honest to myself, I cheated. I didn't do all these integration myself. I used these simple MATLAB code. It is really troublesome to use this method.

clc
w1 = exp(sqrt(2) * x);
w2 = exp(-sqrt(2) * x);
v1d = (x + 1)/sqrt(2) /2 / w1;
v2d = -(x + 1)/sqrt(2) /2 / w2;
g = simplify(int(v1d) * w1 + int(v2d) * w2)
diff(diff(g)) - 2 * g

No comments:

Post a Comment