Time for action - doing multiplication operations
Let us try to perform some of the same operations for multiplication as we did for addition:
octave:75> a*a ans = 4 octave:76> a*b ans = 2 4 6 octave:77> b*b error: operator *: nonconformant arguments (op1 is 1x3, op2 is 1x3) octave:78> b*c ans = 14
What just happened?
From Command 75, we see that *
multiplies two scalar variables just like standard multiplication. In agreement with linear algebra, we can also multiply a scalar by each element in a vector as shown by the output from Command 76. Command 77 produces an error—recall that b
is a row vector which Octave also interprets as a 1 x 3 matrix, so we try to perform the matrix multiplication (1 x 3)(1 x 3), which is not valid. In Command 78, on the other hand, we have (1 x 3)(3 x 1) since c
is a column vector yielding a matrix with size 1 x 1, that is, a scalar. This is, of course, just the dot product between b
and c
.
Let us try an additional example and perform the matrix...