Reflection Matrix

It’s been a while since my last math post. It seems that my previous assertion correlating the quality of question with the period of final exams could not have been further from the truth. It now seems quite likely that the occurrence of a few “good” questions on Yahoo Answers in a short period of time a few weeks back was more of a fluke rather than the norm.

Problem: Find the standard matrix for the linear transformation which reflects points in the x-y plane across the line y = \frac{-2x}{3}.

Solution: To find the matrix representing a given linear transformation all we need to do is to figure out where the basis vectors, i.e.

\vec{e_{1}}=\begin{bmatrix} 1\\ 0 \end{bmatrix} and \vec{e_{2}}=\begin{bmatrix} 0\\ 1 \end{bmatrix}

are mapped under the transformation.

This is easy to see from the fact that since \vec{e_{1}} and \vec{e_{2}} form a basis of \mathbb{R}^{2} any element

\vec{u}\ \epsilon \ \mathbb{R}^{2}

can be written as

\vec{u} = a \cdot \vec{e_{1}} + b \cdot \vec{e_{2}}

for some a,b\ \epsilon\ \mathbb{R}.

Now let

A : \mathbb{R}^{2} \to \mathbb{R}^{2}

be a linear transformation. Then, by definition

A(\vec{u}) = A(a \cdot \vec{e_{1}} + b \cdot \vec{e_{2}}) = a \cdot A( \vec{e_{1}} ) + b \cdot A( \vec{e_{2}} )

Thus, the image of any element \vec{u}\ \epsilon \ \mathbb{R}^{2} under a linear transformation is completely determined by the image of the basis of the transformation’s domain.

Let’s find the image of \vec{e_{1}}=\begin{bmatrix} 1\\ 0 \end{bmatrix} under a reflection across the line given by y = \frac{-2x}{3}. First, we need to find a line perpendicular to y = \frac{-2x}{3} that passed through the point p_{1} = (1, 0).

In general, a line perpendicular to y = mx + b is given by y = \frac{-x}{m}, i.e in our case, y = \frac{3x}{2}. To find the one particular line with the same slope, that passes through p_{1} = (1, 0), we need to simply plug in the values of x = 1 and y = 0 into the line equation and add a constant value so that the equality will hold. Then we have

(0) = \frac{3(1)}{2}+b

Thus, the line perpendicular to y = \frac{-2x}{3} that passes through p_{1} = (1, 0) is given by y = \frac{3x}{2} – \frac{3}{2}

Now let’s find the point q_{1} = (x, y) at which our two lines y = \frac{-2x}{3} and y = \frac{3x}{2} – \frac{3}{2} intersect. This is done easily by solving the two line equation simultaneously:

y = \frac{-2x}{3} \ (1)

y = \frac{3x}{2} – \frac{3}{2} \ (2)

Equating (1) and (2) (and multiplying by 6 for simplicity) gives

-4x = 9x – 9

x = \frac{9}{13}

which then gives

y = \frac{-6}{13}

Thus, our two lines intersect at

q_{1} = \left (\frac{9}{13}, \frac{-6}{13} \right )

Now, let {p_{1}}’ = (x, y) be the reflection of p_{1} = (1, 0) across y = \frac{-2x}{3}. Since {p_{1}}’ and p_{1} are symmetric across q_{1} (because that is how the reflection is actually constructed) it follows that

x = q_{1}x – \left | p_{1}x – q_{1}x \right | = \frac{9}{13} – \left | 1 – \frac{9}{13} \right | = \frac{5}{13}

y = q_{1}y – \left | p_{1}y – q_{1}y \right | = \frac{-6}{13} – \left | 0 – \frac{-6}{13} \right | = \frac{-12}{13}

so

A( \vec{e_{1}} ) = \begin{bmatrix} \frac{5}{13} \\ \frac{-12}{13} \end{bmatrix}

Similarly as above, we find the image of \vec{e_{2}}=\begin{bmatrix} 0\\ 1 \end{bmatrix} under a reflection across the line given by y = \frac{-2x}{3}. The line perpendicular to y = \frac{-2x}{3} that passed through the point p_{2} = (0, 1) is given by

y = \frac{3x}{2} + 1 \ (3)

Equating (1) and (3) (and multiplying by 6 again) gives

-4x = 9x + 6

x = \frac{-6}{13}

and so

y = \frac{4}{13}

Therefore, (1) and (3) intersect at

q_{2} = \left (\frac{-6}{13}, \frac{4}{13} \right )

and the image {p_{2}}’ = (x, y) of p_{2} = (0, 1) under the reflection across y = \frac{-2x}{3} is given by

x = q_{2}x – \left | p_{2}x – q_{2}x \right | = \frac{-6}{13} – \left | 0 – \frac{-6}{13} \right | = \frac{-12}{13}

y = q_{2}y – \left | p_{2}y – q_{2}y \right | = \frac{4}{13} – \left | 1 – \frac{4}{13} \right | = \frac{-5}{13}

which yields

A( \vec{e_{2}} ) = \begin{bmatrix} \frac{-12}{13} \\ \frac{-5}{13} \end{bmatrix}

Finally, the matrix A : \mathbb{R}^{2} \to \mathbb{R}^{2} for the linear transformation which reflects points in the x-y plane across the line y = \frac{-2x}{3} is given by

A = \begin{bmatrix} \frac{5}{13} & \frac{-12}{13} \\ \frac{5}{13} & \frac{-5}{13} \end{bmatrix}

It turns out (although I’m not going to show to derivation here) that in general, the matrix for a linear transformation which reflects points in the x-y plane across an arbitrary line y = mx + b is given by

A = \begin{bmatrix} cos2\theta & sin2\theta \\ sin2\theta & -cos2\theta \end{bmatrix}

where \theta is the angle that the line makes with the positive x-axis, i.e

\theta = arctan(m) if m \geq 0

and

\theta = arctan(\left | m \right |) + \frac{\pi }{2} if m < 0

Golden Nature: Closed-Form Formula For Fibonacci Sequence

Almost everyone has heard of this sequence: 1,\ 1,\ 2,\ 3,\ 5,\ 8,\ etc. It is named after Leonardo of Pisa who introduced it to the western world in one of the most influential books ever published in mathematics – Liber Abaci. This book introduced Europe to the Hindu numerals 0 through 9, the word zero, the notion of an algorithm and the subject of algebra.

The beauty of the Fibonacci sequence and the golden ratio (which is intimately connected to it) lies in that they are not just another mathematical construct, but occur throughout the nature.

Have you ever taken a look at a pine cone and noticed that the scales of the cone are in spirals? Have you ever counted the spiral in the clockwise and counterclockwise directions? I would be surprised if you have … but the counts turn out to be 5 and 8 (or 8 and 13 for bigger cones).

How about these? Care to count the petals?

… intriguing stuff indeed.

So, once again, I was reading through problems on Yahoo Answers. Most of the questions “reduce” (lol) to plugging numbers into well known equations, or using a calculator such as TI-89, or Mathematics, Maple, or even Google – basically, what engineers do. Yeah, you “heard” me right! It takes some effort to found a meaningful question that actually requires some knowledge and skills – see the difference between a mathematician and an engineer now? That said, here’s a one I couldn’t resist:

Problem: Find the term F_{386} in the following sequence F_{0}=-4,\ F_{1}=5,\ F_{2}=1,\ F_{3}=6,\ F_{4}=7,\ F_{5}=13

There is a more “elegant” way to tackle this problem and I may write about in the future (maybe quite soon actually), but for now I’ll ignore matrices, diagonalization and eigenspaces (although the reason why the following solution gives the correct result is tightly connected to linear algebra) and focus, instead, on the recursive nature of the Fibonacci sequence.

Solution: To find the term, “all” that is needed is to find the closed form for the n-th terms of the sequence F_{n}. In general, a Fibonacci sequence is given by

F_{n} = F_{n-1} + F_{n-2}\ (1)

and any particular sequence is fully determined by the initial two terms

F_{0} and F_{1}

In our example, we have

F_{0}=-4 and F_{1}=5

To find the closed form, let’s assume

F_{n}=(-4)\times t^{n}

Then using our recursive formula (1) we get

(-4)t^{n+1}=(-4)\left ( t^{n} + t^{n-1}\right )

and so

t^{2}=t + 1\Rightarrow t^{2} – t – 1 = 0\ (2)

Solving the quadratic from (2) gives

t_{1,2}=\frac{1\pm \sqrt{5}}{2}

Using this result, we can write the closed form formula for the n-th term of our sequence as

F_{n}=-4\left ( \ C_{1}\left ( \frac{1+\sqrt{5}}{2} \right )^{n}+C_{2}\left ( \frac{1-\sqrt{5}}{2} \right )^{n}\ \right ) (3)

where C_{1} and C_{2} are constant parameters determined by our initial conditions,

F_{0}=-4 and F_{1}=5

We can calculate these values by solving the following system of equations

F_{0} = -4\times t^{0}=-4 \left ( C_{1}\times t_{1}^{0} + C_{2}\times t_{2}^{0} \right )

F_{1} = -4\times t^{1}=-4 \left ( C_{1}\times t_{1}^{1} + C_{2}\times t_{2}^{1} \right )

Plugging in known values gives us

-4 = -4 \left (C_{1} \left ( \frac{1+\sqrt{5}}{2} \right )^{0} + C_{2} \left ( \frac{1-\sqrt{5}}{2} \right )^{0} \right )

5 = -4 \left (C_{1} \left ( \frac{1+\sqrt{5}}{2} \right )^{1} + C_{2} \left ( \frac{1-\sqrt{5}}{2} \right )^{1} \right )

Simplifying turns the above into

1 = C_{1} \left ( \frac{1+\sqrt{5}}{2} \right )^{0} + C_{2} \left ( \frac{1-\sqrt{5}}{2} \right )^{0} = C_{1} + C_{2} \ (4)

\frac{-5}{4} = C_{1} \left ( \frac{1+\sqrt{5}}{2} \right ) + C_{2} \left ( \frac{1-\sqrt{5}}{2} \right ) \ (5)

Now we need to solve (4) and (5) for C_{1} and C_{2}. Although I said I was going to leave matrices alone, this is a perfect situation to use them. I prefer to use the procedure described below for a system of two equations with coefficients such as these. Substitution or elimination method would, of course, work, but they involves messy arithmetic which can be so easily error prone in situations such as this one.

We have the following system:

\begin{pmatrix} 1 & 1 \\ \frac{1+\sqrt{5}}{2} & \frac{1-\sqrt{5}}{2} \end{pmatrix} \begin{pmatrix}C_{1}\\ C_{2}\end{pmatrix} = \begin{pmatrix}1\\ \frac{-5}{4}\end{pmatrix}\ (6)

In general, to solve the equation

Au=v

we use

A^{-1}Au=A^{-1}v

which turns into

u=A^{-1}v

Hence, to solve (6) we need to find the inverse of our matrix. This is fairly simple for a 2 by 2 matrix … Let

A=\begin{pmatrix}a & b\\ c & d\end{pmatrix}

then

A^{-1}=\frac{1}{ad-bc}\begin{pmatrix}d & -b\\ -c & a\end{pmatrix}

and so

\begin{pmatrix} 1 & 1 \\ \frac{1+\sqrt{5}}{2} & \frac{1-\sqrt{5}}{2} \end{pmatrix}^{-1} =\frac{-1}{\sqrt{5}}\begin{pmatrix} \frac{1-\sqrt{5}}{2} & -1 \\ \frac{-1-\sqrt{5}}{2} & 1 \end{pmatrix}

Our equation (6) then becomes

\begin{pmatrix} 1 & 1 \\ \frac{1+\sqrt{5}}{2} & \frac{1-\sqrt{5}}{2} \end{pmatrix}^{-1}\begin{pmatrix} 1 & 1 \\ \frac{1+\sqrt{5}}{2} & \frac{1-\sqrt{5}}{2} \end{pmatrix} \begin{pmatrix}C_{1}\\ C_{2}\end{pmatrix} = \begin{pmatrix} 1 & 1 \\ \frac{1+\sqrt{5}}{2} & \frac{1-\sqrt{5}}{2} \end{pmatrix}^{-1} \begin{pmatrix}1\\ \frac{-5}{4}\end{pmatrix}

\begin{pmatrix}C_{1}\\ C_{2}\end{pmatrix} = \frac{-1}{\sqrt{5}}\begin{pmatrix} \frac{1-\sqrt{5}}{2} & -1 \\ \frac{-1-\sqrt{5}}{2} & 1 \end{pmatrix} \begin{pmatrix}1\\ \frac{-5}{4}\end{pmatrix}

which gives us

C_{1}=\frac{-2(1-\sqrt{5})-5}{4\sqrt{5}}\ (7)

C_{2}=\frac{2(1+\sqrt{5})+5}{4\sqrt{5}}\ (8)

Finally, by plugging (7) and (8) into (3) we get

F_{n}=-4\left (\left ( \frac{-2(1-\sqrt{5})-5}{4\sqrt{5}} \right )\left ( \frac{1+\sqrt{5}}{2} \right )^{n}+\left ( \frac{2(1+\sqrt{5})+5}{4\sqrt{5}} \right )\left ( \frac{1-\sqrt{5}}{2} \right )^{n}\right ) (9)

We can now “easily” compute F_{386} which is given by

F_{386}=-4\left (\left ( \frac{-2(1-\sqrt{5})-5}{4\sqrt{5}} \right )\left ( \frac{1+\sqrt{5}}{2} \right )^{386}+\left ( \frac{2(1+\sqrt{5})+5}{4\sqrt{5}} \right )\left ( \frac{1-\sqrt{5}}{2} \right )^{386}\right )

Google returns F_{386} \cong 5.2783459\times 10^{80} which is just an approximation, but now we have a formula for the precise answer.

If you wish to check for yourself that out formula (9) is indeed correct, click on the terms below to see the computation by Google:

F_{0}=-4

F_{1}=5

F_{2}=1

F_{3}=6

F_{4}=7

F_{5}=13

On a side note – Raising a number to the power of 386 may seem like a long computation but it really requires only 10 multiplications! Don’t believe me?

Consider this:

\left ( \frac{1+\sqrt{5}}{2} \right )^{386}=\left ( \frac{1+\sqrt{5}}{2} \right )^{256}\left ( \frac{1+\sqrt{5}}{2} \right )^{128}\left ( \frac{1+\sqrt{5}}{2} \right )^{2}

To calculate

\left ( \frac{1+\sqrt{5}}{2} \right )^{256}

we use the fact that

1.)\ \left ( \frac{1+\sqrt{5}}{2} \right )^{2} = \left ( \frac{1+\sqrt{5}}{2} \right )\left ( \frac{1+\sqrt{5}}{2} \right )

2.)\ \left ( \frac{1+\sqrt{5}}{2} \right )^{4} = \left ( \frac{1+\sqrt{5}}{2} \right )^{2} \left ( \frac{1+\sqrt{5}}{2} \right )^{2}

3.)\ \left ( \frac{1+\sqrt{5}}{2} \right )^{8} = \left ( \frac{1+\sqrt{5}}{2} \right )^{4} \left ( \frac{1+\sqrt{5}}{2} \right )^{4}

8.)\ \left ( \frac{1+\sqrt{5}}{2} \right )^{256} = \left ( \frac{1+\sqrt{5}}{2} \right )^{128} \left ( \frac{1+\sqrt{5}}{2} \right )^{128}

As you can see, in every step (multiplication) we use the result from the previous one and so it takes only 8 steps (multiplications) to calculate

\left ( \frac{1+\sqrt{5}}{2} \right )^{256}

Finally, in the process of calculating

\left ( \frac{1+\sqrt{5}}{2} \right )^{256}

we get

\left ( \frac{1+\sqrt{5}}{2} \right )^{128} and \left ( \frac{1+\sqrt{5}}{2} \right )^{2}

as a bonus, and so to calculate

\left ( \frac{1+\sqrt{5}}{2} \right )^{386}

we now only need to use two more multiplications

\left ( \frac{1+\sqrt{5}}{2} \right )^{386}=\left ( \frac{1+\sqrt{5}}{2} \right )^{256}\left ( \frac{1+\sqrt{5}}{2} \right )^{128}\left ( \frac{1+\sqrt{5}}{2} \right )^{2}

This idea can be generalized to any

x\epsilon \Re

The (maximal) number of multiplications required to compute

x^{n}\ where\ 2^{p}