Vol*_*orm 6 wolfram-mathematica
假设我有一个看起来像这样的矢量:
1/2 a + 1/3 b
b + c
2a + c
1/3c + 4d
Run Code Online (Sandbox Code Playgroud)
在数学上,这可以分解为矩阵和向量:
矩阵:
1/2 1/3 0 0
0 1 1 0
2 0 1 0
0 0 1/3 4
Run Code Online (Sandbox Code Playgroud)
向量:
a
b
c
d
Run Code Online (Sandbox Code Playgroud)
(我对格式化表示歉意,也许有人会建议你做得更好?)
有没有办法让mathematica进行矩阵分解?在我的具体情况中,术语不是简单的表达,例如"a","b","c","d".但事情是由列表索引,例如
W[{3,0,0,0}]
W[{1,1,0,0}]
W[{0,0,1,0}]
Run Code Online (Sandbox Code Playgroud)
谢谢!
可能是:
x = {1/2 a + 1/3 b,
b + c,
2 a + c,
1/3 c + 4 d};
CoefficientArrays[x, {a, b, c, d}][[2]] // MatrixForm
Run Code Online (Sandbox Code Playgroud)
如果您需要所有变量的系数,请使用紧凑形式:
CoefficientArrays[x][[2]] // MatrixForm
Run Code Online (Sandbox Code Playgroud)
在您不想要所有变量的系数的情况下,部分[[1]]起作用:
x2 = {1/2 a + 1/3 b + q - y,
b + c + 1/2 r,
2 a + c + 2 y,
1/3 c + 4 d};
CoefficientArrays[x2, {a, b, c, d}][[1]] // Normal
Run Code Online (Sandbox Code Playgroud)
{q - y, r/2, 2 y, 0}
这样你就可以重建你的表情.