Re: matrices & polynomials in mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg27271] Re: matrices & polynomials in mathematica
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sat, 17 Feb 2001 03:30:43 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <96iqj6$d90@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
two rules ???
f[x_?NumericQ] := 1 + x + x^2
f[x_?MatrixQ] /; Equal @@ Dimensions[x] :=
Module[{n = First[Union[Dimensions[x]]]},
IdentityMatrix[n] + x + Dot[x, x]
]
scan the coefficients of the polynomial for numbers and replace
the numbers by c_?NumericQ :> c*IndentityMatrix[c] and replacing times
by Dot[] may help. But essential the extension of of polynomial to
a matrix is very different from a scalar polynomial.
Regards
Jens
"news.tue.nl" wrote:
>
> Hi,
>
> I have the following problem.
> I have written a mathematica-module that automatically produces a certain
> polynomial as a result. But I want another module to use this first module
> and fill in a matrix in this polynomial.
> for example: f[x]=1+x+x^2
> But when I compute f[A] where A is a matrix, mathematica interprets 1 as a
> matrix filled with ones in stead of the identity-matrix. And A^2 is
> pointswise multiplication in stead of matrix-multiplication.
> Is there an option to let Mathematica know that the polynomial works on
> matrices?
>
> Chris
>
> PS. I am aware of the possibility to multiply matrices using . (dot) but the
> problem is that the polynomial is the result of some computations and I need
> to have mathematica interpret this polynomial on matrices automatically.