I am trying to solve a system of linear equations using the inverse matrix, but am having issues on my last command where I am trying to multiply the inverse matrix by B. Can anyone offer advice on what I am doing wrong?
restart; with(linalg):
sys := {a+.9*h+.8*c+.4*d+.1*e+0*f = 1, .1*a+.2*h+.4*c+.6*d+.5*e+.6*f = .6, .4*a+.5*h+.7*c+d+.6*e+.3*f = .7, .6*a+.1*h+.2*c+.3*d+.5*e+f = .5, .8*a+.8*h+c+.7*d+.4*e+.2*f = .8, .9*a+h+.8*c+.5*d+.2*e+.1*f = .9}:
solve(sys, {a, c, d, e, f, h});
{a = 0.08191850594, c = 0.7504244482, d = 3.510186757,
e = -6.474108659, f = 2.533531409, h = -0.4876910017}
Z := genmatrix(sys, [a, h, c, d, e, f], 'b');
evalm(b);
linsolve(Z, b);
inverse(Z);
B := {`<|>`(`<,>`(1, .6, .7, .5, .8, .9))};
evalm(inverse(Z)&*B);
response is indented below each line where possible. I don't have enough points to put pictures in for matrix results so they have been left blank.
As a previous poster suggests, removing the curly braces will fix your code, however, it may also be worth noting that if you are using a copy of Maple 6 or newer, the linalg package has been deprecated by the newer LinearAlgebra package. Here is equivalent code that uses the LinearAlgebra package:
with(LinearAlgebra):
sys := [a+.9*h+.8*c+.4*d+.1*e+0*f = 1, .1*a+.2*h+.4*c+.6*d+.5*e+.6*f = .6, .4*a+.5*h+.7*c+d+.6*e+.3*f = .7, .6*a+.1*h+.2*c+.3*d+.5*e+f = .5, .8*a+.8*h+c+.7*d+.4*e+.2*f = .8, .9*a+h+.8*c+.5*d+.2*e+.1*f = .9];
solve(sys, {a, c, d, e, f, h});
Z,b := GenerateMatrix(sys, [a, h, c, d, e, f]);
LinearSolve( Z, b );
MatrixInverse( Z );
MatrixInverse( Z ) . b;
One minor difference is that here the GenerateMatrix command returns both the coefficient matrix as well as the right hand side Vector. Also note that I suppressed the output for the with command using the : operator.