Suppose $A$ is a $3 \times 3$ matrix, $B$ is a $3 \times 2$ matrix, $x$ is a 3-component column vector, and $y$ is a $2$-component column vector.
What is the shape of the output (e.g. scalar, $4\times 3$ matrix, 5-component column vector, etcetera) of the following operations, or say nonsense if the operation doesn't make sense.
x .* x
in Julia.)A \ x
in Julia or Matlab), but you can only multiply a column vector by a matrix inverse on the left, while the notation $\frac{x}{A}$ is ambiguous about whether we are "dividing" on the left or right. We have to keep left vs. right crystal clear when working with non-commutative things like matrices, unlike real numbers!x ./ y
in Julia.)(From Strang, section 2.2, problem 11.)
A system of linear equations Ax=b cannot have exactly two solutions. An easy way to see why: if two vectors x and y≠x are two solutions (i.e. Ax=b and Ay=b), what is another solution? (Hint: x+y is almost right.)
For example, $\boxed{\frac{x+y}{2}}$.
To see this, we could start with hint: let's consider $x+y$, which would us $A(x+y)=Ax+Ay=b+b=2b$. This is almost what we want but not quite a solution, since we get $2b$ rather than $b$. We fix it by dividing by $2$ to get $A\left(\frac{x+y}{2}\right)=A\left(\frac{x}{2}\right)+A\left(\frac{y}{2}\right)=\frac{1}{2}Ax+\frac{1}{2}Ay=\frac{b}{2}+\frac{b}{2}=b$.
The key factor here is the linearity of $A$, which allows us to distribute $A$ through vector-addition and scalar-multiplication operations.
Either(ideally) download and install Julia and IJulia/Jupyter by following these instructions, or (slower, less convenient) run Julia in the cloud using these instructions.
A
that takes in any 3-component vector $x$ and outputs ($Ax$) the components in reverse order. For example:A = [ 1 2 3 4
5 6 7 8 ] # this is a 2×4 matrix … not the right answer
3. Multiply A
by the vector x = [1,2,3]
to check that it is doing what you want.
4. Try computing A*A
. The result should be a very simple linear operation: what?
Be sure to include a PDF printout of your notebook with your submitted solutions.
2. First, let's set up the matrix. One way to think of it is by row, since each row of the matrix determines the corresponding row of the output vector. That is, the first row has to pluck the third element from the vector so it should be 0 0 1
, the second row has to pluck the second element so it is 0 1 0
, and the third row has to pluck the first element so it should be 1 0 0
.
A=[0 0 1
0 1 0
1 0 0]
(There are other ways to get the same matrix, of course. This is an example of a permutation matrix, and a simple way to get it is to start with the identity matrix $I$ and apply our re-ordering to the rows. We'll think about this more later in 18.06.)
3. Let's try out our A
:
x=[1,2,3]
A*x
Hooray, it reversed the elements in the output as desired!
4.
Think about what $A$ does: it reverses the order of the components of any vector $x$. The matrix $A^2$ reverses the order twice, which means that it results in the original vector, since the second reversal undoes the first. In other words, $A^2$ must be the identity matrix.
Let's try it and see:
A*A
(Later in the course, we will say that the matrix $A$ is its own inverse: $A^{-1} = A$. This is very special, and is not true of most matrices!)