将表转换为矩阵方程

时间:2014-12-01 17:32:02

标签: matrix wolfram-mathematica differential-equations

我的表看起来像这样:

 {975/2048 - 512 y[1] + 256 y[2]},
 {175/128 + 256 y[1] - 512 y[2] + 256 y[3]},
 {4095/2048 + 256 y[2] - 512 y[3] + 256 y[4]},

我想将其转换为矩阵方程式:

A*y=b

你有什么建议吗? 谢谢!

1 个答案:

答案 0 :(得分:1)

eq = {
     975/2048 - 512 y[1] + 256 y[2],
     175/128 + 256 y[1] - 512 y[2] + 256 y[3],
     4095/2048 + 256 y[2] - 512 y[3] + 256 y[4]} 
 b = -eq /. y[_] -> 0;
 a = Transpose[Table[ D[ eq, y[i]] , {i, 4}]];
 a.Table[ y[i], {i, 4}] == b

 {-512 y[1] + 256 y[2],
   256 y[1] - 512 y[2] + 256 y[3], 
   256 y[2] - 512 y[3] + 256 y[4]} == 
                {-(975/2048), -(175/128), -(4095/2048)}

然后解决:

sol = LinearSolve[a, b];
  

{3155 / 524288,5335 / 524288,4715 / 524288,0}

(eq /. Table[ y[i] -> sol[[i]] , {i, 4}]) == {0, 0, 0}