Array Operations – Division (/ or \)

Matrix Division Of Square Matrices Using the Inverse

Matrix Division is always gently brushed over at school with only the special case of a 2 by 2 square matrix being solved using the inverse of the square matrix. For:

A*B=C

With AInv, the Inverse Matrix of A is defined as:

\displaystyle \text{AInv}=\frac{1}{{ad-bc}}\left( {\begin{array}{*{20}{c}} d & {-b} \\ {-c} & a \end{array}} \right)

Substituting in the numbers:

\displaystyle \text{AInv=}\frac{1}{{\left( {\left( 1 \right)*\left( 4 \right)-\left( 2 \right)*\left( 3 \right)} \right)}}*\left( {\begin{array}{*{20}{c}} 4 & {-2} \\ {-3} & 1 \end{array}} \right)=-\frac{1}{2}\left( {\begin{array}{*{20}{c}} 4 & {-2} \\ {-3} & 1 \end{array}} \right)=\left( {\begin{array}{*{20}{c}} {-2} & 1 \\ {\frac{3}{2}} & {-\frac{1}{2}} \end{array}} \right)

In Octave/MATLAB to find the Inv Matrix we can use the function inv( ):

AInv=AInv(A)

Now when a Matrix is multiplied by it's inverse will give the Identity matrix I:
AInv*A=A*AInv=I

If we multiply the expression

A*B=C

throughout by the inverse of A:

AInv*A*B=AInv*C

I*B=AInv*C

When a Matrix is multiplied by the Identity Matrix it is unchanged

Therefore:

B=AInv*C

This gives the correct value of B.

This can be thought of as:

A(1,1)*B(1,1)+A(1,2)*B(2,1)=C(1,1)
A(1,1)*B(1,2)+A(1,2)*B(2,2)=C(1,2)
A(2,1)*B(1,1)+A(2,2)*B(2,1)=C(2,1)
A(2,1)*B(1,2)+A(2,2)*B(2,2)=C(2,2)

Assuming we don't know the values of B, but we know the values of A and C. This is 4 sets of equations, containing 4 unknowns:

  1. B(1,1)+2*B(2,1)=19
  2. B(1,2)+2*B(2,2)=22
  3. 3*B(1,1)+4*B(2,1)=43
  4. 3*B(1,2)+4*B(2,2)=50

Rearranging 1:

B(1,1)+2*B(2,1)=19
B(1,1)=19-2*B(2,1)

Substituting into 3:

3*(19-2*B(2,1))+4*B(2,1)=43
57-6*B(2,1)+4*B(2,1)=43
-2*B(2,1)=43-57
-2*B(2,1)=-14
B(2,1)=-14/-2
B(2,1)=7

Substituting this into 1 (which was rearranged):

B(1,1)=19-2*B(2,1)
B(1,1)=19-2*7
B(1,1)=19-14
B(1,1)=5

Now rearranging 2:

B(1,2)+2*B(2,2)=22
B(1,2)=22-2*B(2,2)

Now substituting into 4:

3*B(1,2)+4*B(2,2)=50
3*(22-2*B(2,2))+4*B(2,2)=50
66-6*B(2,2)+4*B(2,2)=50
-6*B(2,2)+4*B(2,2)=50-66
-2*B(2,2)=-16
B(2,2)=-16/-2
B(2,2)=8

Substituting this into the rearranged 2:

B(1,2)=22-2*B(2,2)
B(1,2)=22-2*8
B(1,2)=22-16
B(1,2)=6

This gives:

B(1,1)=5
B(1,2)=6
B(2,1)=7
B(2,2)=8

As expected.

Matrix Division

MATLAB can perform Matrix Division. Let's look at the case:

A*B=C

Because A*B≠B*A the notation to solve for A given B and C, or B given A and C is distinct.

Right division is used to calculate A given B and C:

A1=C/B

It is useful to think of this in terms of the square matrices given above where

A1*B=C
A1*B*inv(B)=C*inv(B)
A1=C*inv(B)

With the inverse being on the right hand side (multiplied throughout so it is beside B) so right division is used.

Left division is used to calculate B given A and C:

B1=A\C

It is likewise useful to think of this as

A*B1=C
inv(A)*A*B1=inv(A)*C
B1=inv(A)*C

with the inverse being on the left hand side (multiplied throughout so in is beside A) so left division is used.

Thinking of the left and right divisions in terms of where you would put the inverse helps you put the variables and the left or right division sign in the correct place.

We can use the data we multiplied together to work back from to illustrate division:

Assuming we know S and A and want to calculate E:

E1=A/S

A1=E\A

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.