A p x q matrix A is defined as : A = (a11,.....,a1j,.....,a1q) (. . .) (. . .) (ai1,.....,aij .) (. .) (. .) (ap1,...............,apq) where aij is the element of the matrix A at row ith and column jth
Matrix is treated as a list of list on Mathcalc8. This means that matrix A defined above is viewed as a list of p elements with each elment is itself a list with q elements. Therefore, create a matrix is the same as create a list which we should be very familiar now. As an example, we will show how to create a matrix (Note : Free version of Mathcalc8 do not support matrix calculation) :
Enter a 2 x 3 matrix a = (1, 2, 3) (4, 5, 6)
Ans. set a = 1, 2, 3, 4, 5, 6
We can see that a is defined as a list of two elements. (1, 2, 3) is the first element and (4, 5, 6) is the second element. Both elements are also a list. To show the first row of a :
Ans. 1, 2, 3
Mathcalc8 do not have a way to show individual element of a (input a(0)(1) do not work). So when we want to change one element of the matrix, say, change the first row, second column element from 2 to -1, we need to click the 'Dec' button to go back to Input 1 and make the change or we can use the following trick :
Ans. set b = 1, 2, 3
Ans. set b = 1, -1, 3
Ans. set a(0) = 1, -1, 3
Ans. 1, -1, 3, 4, 5, 6
We can see that b is used as an intermediate variable to make the change. Now, the original value of 2 in matrix a was changed to -1.
Next, we show how to get the transpose of matrix a through the function 'trans' :
Ans. set b = 1, 4, -1, 5, 3, 6
The first row of b is :
Ans. 1, 4
The second row of b is :
Ans. -1, 5
The third row of b is :
Ans. 3, 6
So, we can see that b is a 3 x 2 matrix.
One precaution about matrix definition is on the definition of n x 1 matrix. For example, if we want to define a 3 x 1 matrix as follow :
a = (1) (2) (3)
We should not define it by setting a=((1),(2),(3))! Instead, we need to define the matrix using the function 'trans' as follow :
Ans. set a = 1, 2, 3
Ans. 1
Next, we would show how to do matrix arithmetic. They are similar to list arithmetic except that there is two kind of multiplication for matrix :
1. Addition and Subtraction uses the same symbol '+' and '-' :
Add (1, 2) + (5, 6) (3, 4) (7, 8)
Ans. 6, 8, 10, 12
Subtract (1, 2) - (5, 6) (3, 4) (7, 8)
Ans. -4, -4, -4, -4
Add 1 + (5, 6) (7, 8)
Ans. 6, 7, 8, 9
Subtract 1 - (5, 6) (7, 8)
Ans. -4, -5, -6, -7
2. Scale multiplication and division also uses same symbol '*' and '/' :
Multiply 2 x (1, 2) (3, 4)
Ans. 2, 4, 6, 8
Division (1, 2) / 2 (3, 4)
Ans. 0.5, 1, 1.5, 2
3. Matrix-matrix multiplication, we need to use function 'mmult' for standard matrix multiply :
Matrix Multiply (1, 2) x (5, 6) (3, 4) (7, 8)
Ans. 19, 22, 43, 50
If we use '*' to do matrix multiplication, the multiplication would be done on the same position of elements between the two matrix :
Multiply (1, 2) x (5, 6) (3, 4) (7, 8)
Ans. 5, 12, 21, 32
Matrix Multiply (2,-6) x (5) (3)
Ans. -8
Matrix Multiply (5) x (2,-6) (3)
Ans. 10, -30, 6, -18
Matrix Multiply (2, 1) x (-1, 6) (4, 3) ( 3, 2) (1, 2)
Ans. 1, 14, 5, 30, 5, 10
Next, we define two matrix a and b as follow :
a = (-2 , 4, 3+2i) b = (5, 1, -4) (1 , 6, -7) (1, 3, -3i)
1. Evaluate 2a - 3b :
Ans. 19, 5, 18+4i, -1, 3, -14+9i
2. Evaluate abT. The symbol 'T' means 'transpose' :
(-2 , 4, 3+2i) x (5, 1) (1 , 6, -7) (1, 3) (-4,-3i)
Ans. -18-8i, 16-9i, 39, 19+21i
3. Evaluate abH. The symbol 'H' means 'Hermitian transpose', (i.e. the matrix is being transposed and then take complex conjugate for all its elements). To take complex conjugate for a complex number means that we change the sign of the complex number's imaginary part with the real part kept fixed. In Mathcalc8, this is done by using the function 'conj' :
(-2 , 4, 3+2i) x (5, 1) (1 , 6, -7) (1, 3) (-4, 3i)
Ans. -18-8i, 4+9i, 39, 19-21i
4. Evaluate aTb :
(-2, 1) x (5, 1, -4) (4, 6) (1, 3, -3i) (3+2i,-7)
Ans. -9, 1, 8-3i, 26, 22, -16-18i, 8+10i, -18+2i, -12+13i
5. Evaluate aHb :
(-2, 1) x (5, 1, -4) (4, 6) (1, 3, -3i) (3-2i,-7)
Ans. -9, 1, 8-3i, 26, 22, -16-18i, 8+10i, -18-2i, -12+29i
6. Evaluate trace(abH). The trace of a matrix a is equal to the summation of all of its diagonal elements aii :
Ans. set tr = 0
Ans. 1-29i
7. Evaluate (abH)5 :
Ans. 13935162-1400900i, -603116-5405403i, -2052971-6510816i, -7712021-734589i
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.