online advertising

Friday, January 1, 2016

Second order constant coefficients (III)

Problem:

2y'' - 3y' + 6y = 0

Solution:

The solutions to the characteristic polynomial are $ \frac{3 \pm \sqrt{39}i}{4} $

Skipping all the derivation we have already done in the last post, the answer is

$ y = Ae^{\frac{3}{4}}\cos\frac{\sqrt{39}}{4}x + Be^{\frac{3}{4}}\sin\frac{\sqrt{39}}{4}x $

Second order constant coefficients (II)

Problem:

$ y'' + y' + y = 0 $

Solution:

The characteristic polynomial is $ x^2 + x + 1 = 0 $, the solution is $ \frac{-1 \pm \sqrt{1^2 - 4(1)(1)}}{2(1)} = \frac{-1 \pm \sqrt{3} i}{2} $

Therefore the answer is

$ y = Ae^{\frac{-1 + \sqrt{3} i}{2}x} + Be^{\frac{-1 - \sqrt{3} i}{2}x} $

Separating out the real and imaginary parts, we get

$ y = Ae^{\frac{-1}{2}x} e^{\frac{\sqrt{3} i}{2}x} + Be^{\frac{-1}{2}x}e^{\frac{- \sqrt{3} i}{2}x} $

Next we can apply the Euler's formula

$ y = Ae^{\frac{-1}{2}x} (\cos\frac{\sqrt{3}}{2}x + i\sin\frac{\sqrt{3}}{2}x) + Be^{\frac{-1}{2}x}(\cos\frac{\sqrt{3}}{2}x - i\sin\frac{\sqrt{3}}{2}x) $

Grouping the real and imaginary gives:

$ y = Ae^{\frac{-1}{2}x} \cos\frac{\sqrt{3}}{2}x  + Be^{\frac{-1}{2}}\cos\frac{\sqrt{3}}{2}x + Ae^{\frac{-1}{2}}\sin(\frac{\sqrt{3}}{2}x)i - Be^{\frac{-1}{2}x}\sin(\frac{\sqrt{3}}{2}x)i $

Factorize, we get:

$ y = (A + B) e^{\frac{-1}{2}x} \cos\frac{\sqrt{3}}{2}x + (A-B)e^{\frac{-1}{2}}\sin(\frac{\sqrt{3}}{2}x)i $

There are two ways we can make the expression real, either we set $ A = B $, that get rid of the imaginary part, or we can set $ A = -B $ be a pure imaginary number, that essentially get rid of the real part and make the imaginary part real. That gives the answer as:

$ y = C e^{\frac{-1}{2}x} \cos\frac{\sqrt{3}}{2}x + D e^{\frac{-1}{2}}\sin\frac{\sqrt{3}}{2}x $

Thursday, December 31, 2015

On repeated roots

Following up with the last post, we wanted to understand why $ xe^{-2x} $ is the solution when $ -2 $ is a repeated root.

Let's start with this, $ (p(x) e^{ax})^{(k)} $

We notice this pattern

$ (p(x)e^{ax})' = e^{ax}(ap(x) + p'(x)) $
$ (p(x)e^{ax})'' = e^{ax}(a^2p(x) + 2ap'(x) + p''(x)) $
$ (p(x)e^{ax})''' = e^{ax}(a^3p(x) + 3a^2p'(x) + 3ap''(x) + p'''(x)) $

Feel like binomial expansion? Let's prove this.

Let $ S(n) $ be the statement $ (p(x)e^{ax})^{(n)} = e^{ax}\sum\limits_{i=0}^{n}(\left(\begin{array}{c}n\\i\end{array}\right)a^i p^{(n-i)}(x)) $

$ S(0) $ is obviously true, now let's assume $ S(k) $ is true and

$ (p(x)e^{ax})^{(k)} = e^{ax}\sum\limits_{i=0}^{k}(\left(\begin{array}{c}k\\i\end{array}\right)a^i p^{(k-i)}(x)) $

Now we differentiate both sides once more, we get

$ (p(x)e^{ax})^{(k+1)} = e^{ax} (\sum\limits_{i=0}^{k}(\left(\begin{array}{c}k\\i\end{array}\right)a^i p^{(k-i)}(x)))' + ae^{ax}\sum\limits_{i=0}^{k}(\left(\begin{array}{c}k\\i\end{array}\right)a^i p^{(k-i)}(x)) $

Don't be shied away from the first term, it is just differentiating polynomials, so adding 1 to the differentiation times and that's all. grouping terms, we will get

$ \begin{eqnarray*} (p(x)e^{ax})^{(k+1)} &=& e^{ax} \sum\limits_{i=0}^{k}(\left(\begin{array}{c}k\\i\end{array}\right)a^i p^{(k+1-i)}(x)) + ae^{ax}\sum\limits_{i=0}^{k}(\left(\begin{array}{c}k\\i\end{array}\right)a^i p^{(k-i)}(x)) \\ &=& e^{ax} \sum\limits_{i=0}^{k}(\left(\begin{array}{c}k\\i\end{array}\right)a^i p^{(k+1-i)}(x)) + ae^{ax}\sum\limits_{i=1}^{k+1}(\left(\begin{array}{c}k\\i - 1\end{array}\right)a^{i-1} p^{(k+1-i)}(x)) \\ &=& e^{ax} \sum\limits_{i=0}^{k}(\left(\begin{array}{c}k\\i\end{array}\right)a^i p^{(k+1-i)}(x)) + e^{ax}\sum\limits_{i=1}^{k+1}(\left(\begin{array}{c}k\\i - 1\end{array}\right)a^i p^{(k+1-i)}(x)) \\ &=& e^{ax} \left(\begin{array}{c}k\\0\end{array}\right)a^0 p^{(k+1-0)}(x) + e^{ax} \sum\limits_{i=1}^{k}(\left(\begin{array}{c}k\\i\end{array}\right)a^i p^{(k+1-i)}(x)) + e^{ax}\sum\limits_{i=1}^{k}(\left(\begin{array}{c}k\\i - 1\end{array}\right)a^i p^{(k+1-i)}(x)) + e^{ax}\left(\begin{array}{c}k\\k+1 - 1\end{array}\right)a^{k+1} p^{(k+1-(k+1))}(x) \\ &=& e^{ax} a^0 p^{(k+1)}(x) + e^{ax} \sum\limits_{i=1}^{k}(\left(\begin{array}{c}k\\i\end{array}\right)a^i p^{(k+1-i)}(x)) + e^{ax}\sum\limits_{i=1}^{k}(\left(\begin{array}{c}k\\i - 1\end{array}\right)a^i p^{(k+1-i)}(x)) + e^{ax}a^{k+1} p^{(0)}(x) \\ &=& e^{ax} a^0 p^{(k+1)}(x) + e^{ax} \sum\limits_{i=1}^{k}(\left(\left(\begin{array}{c}k\\i\end{array}\right)+\left(\begin{array}{c}k\\i-1\end{array}\right)\right)a^i p^{(k+1-i)}(x)) + e^{ax}a^{k+1} p^{(0)}(x) \\ &=& e^{ax} a^0 p^{(k+1)}(x) + e^{ax} \sum\limits_{i=1}^{k}(\left(\begin{array}{c}k + 1\\i\end{array}\right)a^i p^{(k+1-i)}(x)) + e^{ax}a^{k+1} p^{(0)}(x) \\ &=& e^{ax} \sum\limits_{i=0}^{k+1}(\left(\begin{array}{c}k + 1\\i\end{array}\right)a^i p^{(k+1-i)}(x)) \\ \end{eqnarray*} $

Well, a little more complicated than I wanted it to be, but I proved the result.

Next, we assume the differential equation has constant coefficient like this $ \sum\limits_{j=0}^{n} c_j y^{(j)} = 0 $, and that $ r $ is a root of multiplicity $ k $. In this case, we claim $ x^m e^{rx} $ is a solution for the differential equation for $ 0 \le m < k $. All we need to do is to put it back to the equation and use our result above:

$ \begin{eqnarray*} & & \sum\limits_{j=0}^{n} c_j y^{(j)} \\ &=& \sum\limits_{j=0}^{n} c_j e^{rx}\sum\limits_{i=0}^{j}(\left(\begin{array}{c}j\\i\end{array}\right)r^i p^{(j-i)}(x)) \\ &=& e^{rx} \sum\limits_{j=0}^{n} c_j \sum\limits_{i=0}^{j}(\left(\begin{array}{c}j\\i\end{array}\right)r^i p^{(j-i)}(x)) \\ &=& e^{rx} \sum\limits_{j=0}^{n} c_j \sum\limits_{i=0}^{j}(\left(\begin{array}{c}j\\i\end{array}\right)r^{j-i} p^{(i)}(x)) \\ &=& e^{rx} \sum\limits_{i=0}^{n} \sum\limits_{j=i}^{n} c_j (\left(\begin{array}{c}j\\i\end{array}\right)r^{j-i} p^{(i)}(x)) \\ &=& e^{rx} \sum\limits_{i=0}^{n} \sum\limits_{j=i}^{n} c_j (\frac{j!}{i! (j-i)!}r^{j-i} p^{(i)}(x)) \\ &=& e^{rx} \sum\limits_{i=0}^{n} \frac{p^{(i)}(x)}{i!} \sum\limits_{j=i}^{n} c_j (\frac{j!}{(j-i)!}r^{j-i} ) \\ \end{eqnarray*} $

Note that the inner summation is really just the characteristics polynomial differentiated $ i $ times evaluated at $ r $, and we know $ r $ is a root of multiplicity $ k $, so for all $ i < k $, the term is zero.

For the other terms, we differentiated $ p(x) $ at least $ k $ times, but $ p(x) = x^m $, so the derivative vanishes, and those terms go to 0 as well. Combining the two facts, the differential equation is satisfied, and therefore it is a solution!

Q.E.D.

The magic step of the fourth equal sign probably need some explanation. One can better visualize that if one programs, it is basically a loop transformation

for (j = 0 to n) { for (i = 0 to j } { } }

is transformed to

for (i = 0 to n) { for (j = i to n } { } }

The easiest way to see why this transformation is valid is by generating the (i, j) tuples created by these loops.

Tuesday, December 29, 2015

Second order constant coefficients (I)

Problem:

$ y'' + 4y' + 4y = 0 $

Solution:

Note that we do not have the independent variable $ x $, in principle we could have reduce to order to 1, but for this one let's try the solution $ y = e^{rx} $. Putting the solution in the problem, we have

$ r^2e^{rx} + 4re^{rx} + 4e^{rx} = 0 $

Solving, get $ r = -2 $ (repeated).

The repeated solution worried me because then we have only one degree of freedom.

Let's try $ y = xe^{rx} $, $ y' = e^{rx} + rxe^{rx} $, $ y'' = re^{rx} + re^{rx} + r^2xe^{rx} $

$ y'' + 4y' + 4y = (re^{rx} + re^{rx} + r^2xe^{rx}) + 4(e^{rx} + rxe^{rx}) + 4(xe^{rx}) $
$  = e^{rx}((r + r + r^2x) + 4(1 + rx) + 4(x)) $
$  = e^{rx}(2r + 4+ (r^2 + 4r + 4)) $

So if we put $ r = -2 $, the equation still work out, so the solution is

$ Ae^{-2x} + Bxe^{-2x} $.

To be honest, I kind of know $ xe^{-2x} $ is an answer when I see the double root. I know it because of my experience (sort of my teacher told me so thing). But wouldn't it be more satisfying if we figured out the general rule and why the general rule work? Let's investigate in the next post.

Monday, December 28, 2015

Reduction of order (II)

Problem:

$ y'' - y'y = 0 $

Solution:

This time we see $ x $ does not appear in the equation, we can let $ z = y' $ and $ y'' = \frac{dz}{dx} = \frac{dz}{dy}\frac{dy}{dx} = z'z $, note that $ z' $ denote $ \frac{dz}{dy} $.

The equation becomes

$ \begin{eqnarray*} y'' - y'y &=& 0 \\ z'z - z y &=& 0 \\ z'z &=& z y \\ z' &=& y \\ z &=& \frac{y^2}{2} + c_1 \\ y' &=& \frac{y^2}{2} + c_1 \\ \frac{2dy}{y^2 + c_2^2} &=& dx \\ 2 \arctan(y/c_2)/c_2 &=& x + c_3 \\ \arctan(y/c_2) &=& \frac{c_2x + c_4}{2} \\ y/c_2 &=& \tan\frac{c_2x + c_4}{2} \\ y &=& c_2 \tan\frac{c_2x + c_4}{2} \\ y &=& 2 c_5 \tan(c_5x + c_6) \\ \end{eqnarray*} $

Check:

$ \begin{eqnarray*} y &=& 2 c_5 \tan(c_5x + c_6) \\ y' &=& 2 c_5 \sec^2(c_5x + c_6) (c_5) \\ &=& 2 c_5^2 \sec^2(c_5x + c_6) \\ y'' &=& 2 c_5^2 (2 \sec(c_5x + c_6))(\sec(c_5x + c_6) \tan(c_5x + c_6)) (c_5) \\ &=& 4 c_5^3 \sec^2(c_5x + c_6) \tan(c_5x + c_6) \end{eqnarray*} $

Reduction of order (I)

Problem:

$ y'' - y' = x $

Solution:

y is missing from the equation, so we can simply let $ z = y' $ and so $ y'' = z' $. The equation is reduced to

$ \frac{dz}{dx} - z = x $

This is a first order linear equation, by inspection, the integrating factor is $ e^{-x} $, we have

$ \frac{d}{dx}(e^{-x} z) = e^{-x} \frac{dz}{dx} - e^{-x} z = e^{-x} (\frac{dz}{dx} - z) = x e^{-x} $.

Therefore $ e^{-x} z = \int {x e^{-x} dx } = - xe^{-x} - e^{-x} + C_1 $.

Then we have $ z = -x - 1 + C_1e^x $

Last but not least, $ y = \int z dx = -\frac{x^2}{2} - x + C_1e^x + C_2 $.

Logic Riddle

Problem:



Solution:

If it is in box 1, then message 1 is false, message 2 is true, message 3 is false. [Good!]
If it is in box 2, then message 1 is true, message 2 is false, message 3 is true. [Bad!]
If it is in box 3, then message 1 is true, message 2 is true, message 3 is false. [Bad!]

So it is in box1!