mathematica中怎樣進行矩陣初等行變換

時間 2021-06-08 07:58:54

1樓:紐澤西管風琴

有三種初等行變換:

將矩陣的第行和第行交換;

將矩陣的第行乘以乙個係數;

將矩陣的第行加上第行的倍。

分別對應三個函式:

swap[m_

,i_,j_

]:=Permute[m

,Cycles@}]

times[m_

,i_,k_

]:=MapAt[k

#&,m

,i]add[m_

,i_,j_

,k_]:=

MapAt[#

+km[[

j]]&,

m,i]

作為例子,定義函式 reduce 進行 Gauss–Jordan 消元,

reduce[m_

]:=Block

[,Table[s

=times[s

,i,1

/s[[i

,i]]];

Table[s

=add[s

,j,i

,-s[[

j,i]]];,

],];

Table

[Table[s

=add[s

,j,i

,-s[[

j,i]]];,

];,];s]

定義函式 myInverse,利用 Gauss–Jordan 消元求逆矩陣,

myInverse[m_

]:=reduce

[ArrayFlatten

@}][[

All,

-Length@m

;;]]

用隨機生成的矩陣驗證這個函式,s=

RandomReal[1

,];Chop

[myInverse[s

].s]

//MatrixForm

輸出:1.00

001.0

0001.

00001.

Mathematica 中如何定義 f x y f x f y ?

Attributes f HoldAll f a Plus f Unevaluated a 寫完了才想起來上面這種複雜的寫法其實毫無必要。最簡單的就足夠了 ClearAll f Attributes f HoldAll f x y f x f y f a b c f a f b f c 因為Plus...

mathematica中,如何生成下面這樣乙個離散過程的轉移矩陣?

我是這樣解決的 用1到 X1 1 Y1 1 Z1 1 的乙個數t H Y1 1 Z1 1 m Z1 1 n 1代表乙個狀態 H,m,n 然後求這樣乙個 X1 1 Y1 1 Z1 1 2的矩陣.Module prob i j Module H1 Quotient i 1,d2 d3 m1 Quotie...

mathematica中畫圖函式的區分?

吉聆遠 具體的區別 withparadox2 已經說得很明晰了。但對於 3,當不好求出顯示解時,如 x 2 Sin y Cos x y,不好寫出以上兩種形式時便可以用ContourPlot ImplicitPlot淘汰掉 來繪製,例如 ContourPlot x 2 Sin y Cos x y,我來...