MatrixFunction
A scalar function f extended to a square matrix m, via its eigendecomposition. Provided by @enumeratio/analytic.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram Language
MatrixFunction✓MatrixFunction(f, m)f applied to the square matrix m, via its eigendecomposition.SymPy
Matrix(m).analytic_func(f, Symbol("_mf")).applyfunc(simplify).tolist()Typed signatures
| Type | Package | Applies |
|---|---|---|
(function, matrix) -> matrix | analytic | always |
Details
- Exact where the structure gives one: a diagonal m (any size, including symbolic entries) reduces to elementwise f down the diagonal; f = Exp reduces to MatrixExp for any m; a 2×2 m otherwise reduces to Lagrange's formula at its two eigenvalues, with the Jordan-block limit f(λ)·I + f′(λ)·(M − λI) (f′ via compute-engine's own D) when they coincide.
- No general n×n closed form past that: a non-diagonal matrix larger than 2×2 needs a numerical-linear-algebra kernel (Parlett recurrence or a Schur form), which this does not implement -- those calls stay symbolic.
Examples
Basic #
About
| Examples | 12 |
|---|---|
| Checked against | Wolfram Language 11 agree1 unevaluatedSymPy 6 agree3 differ1 error |
| Crosswalk | Wolfram LanguageSymPy |
Implementation
mapped
sympypackages/oracle/src/mappings.tsSymPy's Matrix.analytic_func(f(x), x) takes f as an expression of one variable, which the emitter builds from a head's name or a Function's body (an undefined name becomes an unknown function). It evaluates through the Jordan form, so it is the same function of the matrix; each entry is then simplified (the Lagrange form it builds for distinct eigenvalues is otherwise unreadable), so Simplify of a MatrixFunction is the call itself. A repeated eigenvalue's derivative comes back as a Subs(Derivative(f(x), x), x, a). A constant f has no variable for it to use and is an error there.
See also: MatrixExp, MatrixPower