Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2024-01-21 17:31:12

lanxiyu
Member
Registered: 2022-05-10
Posts: 52

Mathematica implementation of matrix functions

(* Differentiable function *)
MatrixSqrt[m_] := MatrixPower[m, 1/2]
MatrixSin[m_] := (MatrixExp[I*m]-MatrixExp[-I*m])/(2*I)
MatrixCos[m_] := (MatrixExp[I*m]+MatrixExp[-I*m])/2
MatrixTan[m_] := -I*(MatrixExp[I*m]-MatrixExp[-I*m]).Inverse[MatrixExp[I*m]+MatrixExp[-I*m]]
MatrixCot[m_] := I*(MatrixExp[I*m]+MatrixExp[-I*m]).Inverse[MatrixExp[I*m]-MatrixExp[-I*m]]
MatrixSec[m_] := Inverse[MatrixCos[m]]
MatrixCsc[m_] := Inverse[MatrixSin[m]]
MatrixSinh[m_] := (MatrixExp[m]-MatrixExp[-m])/2
MatrixCosh[m_] := (MatrixExp[m]+MatrixExp[-m])/2
MatrixTanh[m_] := (MatrixExp[m]-MatrixExp[-m]).Inverse[MatrixExp[m]+MatrixExp[-m]]
MatrixCoth[m_] := (MatrixExp[m]+MatrixExp[-m]).Inverse[MatrixExp[m]-MatrixExp[-m]]
MatrixSech[m_] := Inverse[MatrixCosh[m]]
MatrixCsch[m_] := Inverse[MatrixSinh[m]]
(* From polar decomposition *)
MatrixSign[m_] := Module[{u,s,v},{u,s,v}=SingularValueDecomposition[m];u.ConjugateTranspose[v]]

Offline

Board footer

Powered by FluxBB