2014-12-01 81 views
0

我的表看起來像這樣:表格轉換成矩陣方程

{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
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]; 

{524288分之3155,524288分之5335,524288分之4715,0}

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