MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: matrices & polynomials in mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27277] Re: [mg27273] matrices & polynomials in mathematica
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Sat, 17 Feb 2001 03:30:50 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Well, here is a function that shoudl do what you want:

PolynomialMatrix[p_, x_][A_?MatrixQ] /; PolynomialQ[p, x] :=
  Module[{u = CoefficientList[p, x], l, X}, l = Length[u];
    u.(MatrixPower[X, #] & /@ Range[0, l - 1]) /. X -> A]

For example, let 

p = 2 + 3x + 5x^2;

A = {{1, 2}, {1, -2}};

then

In[5]:=
PolynomialMatrix[p, x][A]

Out[5]=
{{20, -4}, {-2, 26}}

To see more clearly if this works let's try a case where we know what the
answeris:

In[6]:=
p = Det[x*IdentityMatrix[2] - A] // Expand

Out[6]=
          2
-4 + x + x

In[7]:=
PolynomialMatrix[p, x][A]

Out[7]=
{{0, 0}, {0, 0}}

So it seems to work.


-- 
Andrzej Kozlowski
Toyama International University
JAPAN

http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/





on 01.2.16 5:58 PM, news.tue.nl at student at 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.
> 
> 
> 
> 
> 



  • Prev by Date: Re: two y-axis
  • Next by Date: Re: numerics
  • Previous by thread: Re: matrices & polynomials in mathematica
  • Next by thread: Re: matrices & polynomials in mathematica