I have a zero matrix in Maple and I need to replace some of its entries with some non zero elements. How do I do that? I also want to find the inverse of the new matrix after replacement.
If you created the Matrix by using the Matrix
command then, by default, all its entries are zero. In that case you can subsequently assign to them as you wish, using indexed assignment.
M:=Matrix(2,2):
M;
[0 0]
[ ]
[0 0]
M[2,2]:=3.7:
M;
[0 0 ]
[ ]
[0 3.7]
The command to compute the inverse is LinearAlgebra:-MatrixInverse
. Eg,
M:=Matrix(2,2):
M[2,2]:=3.7:
M[2,1]:=4.1:
M[1,2]:=-0.3:
M[1,1]:=5.9:
M;
[5.9 -0.3]
[ ]
[4.1 3.7 ]
Minv:=LinearAlgebra:-MatrixInverse(M):
Minv;
[0.160450997398092 0.0130095403295750]
[ ]
[-0.177797051170859 0.255854293148309 ]
M . Minv;
[1. 0.]
[ ]
[0. 1.]
See the help page for topic LinearAlgebra
for more.