【问题标题】:solving Ax=b using inverse matrix in maple在 Maple 中使用逆矩阵求解 Ax=b
【发布时间】:2017-02-19 13:20:50
【问题描述】:

我正在尝试使用逆矩阵求解线性方程组,但是在我尝试将逆矩阵乘以 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);

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

【问题讨论】:

    标签: physics linear-algebra maple


    【解决方案1】:

    正如之前的海报所暗示的,删除花括号将修复您的代码,但是,如果您使用 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 命令返回系数矩阵以及右手边的向量。另请注意,我使用 : 运算符抑制了 with 命令的输出。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2014-04-05
        • 2018-08-06
        • 1970-01-01
        • 2018-10-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-06
        • 1970-01-01
        相关资源
        最近更新 更多