# Solve Linear equations

1. Nov 30, 2012

### phynewb

Hi guys

I wonder if you know any linear algebra formalism or something to solve the following question systematically?

Give A,B with A=n1xn2 matrix and B=n1xm2 matrix.
How do we get C=n2xm2 matrix such that A*C=B.
A simple example if A=(1,2)^t, B=(2,4)^t, then C=2

The question is how to solve C given A and B.
Thanks

2. Dec 1, 2012

### HallsofIvy

That depends upon how many dimensions A and B have. In the example you give the simplest method is the write out the components and solve the resulting system of equations. Since A is "1 by 2" and B is "2 by 1", C must be a 1 by 1 matrix (a single number) and AC= B becomes
$$\begin{bmatrix}1 \\ 2\end{bmatrix}\begin{bmatrix}c\end{bmatrix}= \begin{bmatrix}c \\ 2c\end{bmatrix}= \begin{bmatrix}2 \\ 4\end{bmatrix}$$
which gives the two equations c= 2 and 2c= 4 so that c= 2. Of course, if B has NOT been a simple multiple of A, there would not have been any solution.

3. Dec 1, 2012

### AlephZero

If you think about how matrix multiplication AC is defined, the i'th column of C only affects the i'th column of B.

So you only need to consider the simpler problem where C and B are vectors.

This is just a set of linear equations, which may have zero, one, or more than one solution depending on the row and column dimensions of A and the rank of A. The details should be covered in any course on linear algebra, or numerical methods for solving linear equations.

4. Dec 3, 2012

### phynewb

Thanks AlephZero and HallsofIvy.

I guess the example is too simple.
I like to consider the general case.
Here is the way I solve it.
Want to solve C with AC=B.
Multiply A^t on both sides A^t.A.C=A^t.B
Now A^t.A^t is a square matrix so I can calculate its inverse (if it is not singular)
Then I get C=(A^t.A)^-1.A^t.B (1)

However if I calculate C in this way, something goes wrong!
For example,
Say A=[1,2]^t, B=[[1,0,2],[2,1,0]]
By(1) C=1/5[5,2,2]
But A.C=1/5[[5,2,2],[10,4,4]]\=B.
So I wonder what is wrong with (1).
Why does (1) get correct C such that A.C=B?