online advertising
Loading [MathJax]/jax/output/HTML-CSS/jax.js

Friday, January 1, 2016

The method of variation of parameter (I)

Problem:

y2y=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)=w1(x) and w(x)=w2(x).

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

y(x)=v1(x)w1(x)+v2(x)w2(x).

Computing the first derivative, we get:

y(x)=v1(x)w1(x)+v1(x)w1(x)+v2(x)w2(x)+v2(x)w2(x).

As a wishful thinking, let's assume v1(x)w1(x)+v2(x)w2(x)=0. This is one of the equation that govern v1(x) and v2(x).

Next, we compute the second derivative, we get:

y(x)=v1(x)w1(x)+v2(x)w2(x).
y(x)=v1(x)w1(x)+v1(x)w1(x)+v2(x)w2(x)+v2(x)w2(x).

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

(v1(x)w1(x)+v1(x)w1(x)+v2(x)w2(x)+v2(x)w2(x))+p(x)(v1(x)w1(x)+v2(x)w2(x))+q(x)(v1(x)w1(x)+v2(x)w2(x))=r(x).

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

v1(x)w1(x)+v2(x)w2(x)+(v1(x)w1(x)+p(x)v1(x)w1(x)+q(x)v1(x)w1(x))+(v2(x)w2(x)+p(x)v2(x)w2(x)+q(x)v2(x)w2(x))=r(x).

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

v1(x)w1(x)+v2(x)w2(x)=r(x).

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

So much for the theory, now we solve the equation y2y=x+1.

The homogeneous equation w2w=0 is pretty easy to solve, it is simply w1(x)=e2x and w2(x)=e2x.

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

v1(x)e2x+v2(x)e2x=0
2v1(x)e2x+(2)v2(x)e2x=x+1

Cancelling the 2 factor from the second equation we get

v1(x)e2xv2(x)e2x=x+12

Now the functions are trivial to solve v1(x)=x+122e2x, v2(x)=x122e2x.

Next we integrate to find v1(x) and v2(x).

v1(x)=18(2x+2+2)e2x
v2(x)=18(2x2+2)e2x

Putting these back to the differential equation, we finally get

y(x)=v1(x)w1(x)+v2(x)w2(x)=18(2x+2+2)+18(2x2+2)=12(x+1).

And the final answer is, of course, y(x)=12(x+1)+Ae2x+Be2x.

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