在 maple 中使用逆矩阵求解 Ax=b

solving Ax=b using inverse matrix in maple

我正在尝试使用逆矩阵求解线性方程组,但在我尝试将逆矩阵乘以 B 的最后一个命令中遇到问题。任何人都可以就我做错了什么提供建议?

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);

响应在可能的情况下缩进在每行下方。我没有足够的点来为矩阵结果放入图片,所以它们留空了。

只需删除 B 中的大括号即可。

B := `<|>`(`<,>`(1, .6, .7, .5, .8, .9));
evalm(inverse(Z)&*B);

正如之前的海报所建议的那样,删除大括号将修复您的代码,但是,可能还值得注意的是,如果您使用的是 Maple 6 或更新版本的副本,linalg 包已被较新的 LinearAlgebra 包弃用。 这是使用 LinearAlgebra 包的等效代码:

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; 

一个细微的区别是这里的 GenerateMatrix 命令 returns 系数矩阵和右侧向量。另请注意,我使用 : 运算符抑制了 with 命令的输出。