MathGroup Archive 2003

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

Search the Archive

Re: Evaluating a polynomial on a matrix; matrix computations over a finite field

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43134] Re: [mg43123] Evaluating a polynomial on a matrix; matrix computations over a finite field
  • From: Selwyn Hollis <selwynh at earthlink.net>
  • Date: Thu, 14 Aug 2003 05:07:50 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

The key is to replace Power with MatrixPower, and constants need to be 
replaced by a multiple of IdentityMatix[n]. The following function 
seems to work pretty well:

matp[poly_,x_Symbol][A_?MatrixQ /;
		First[Dimensions[A]]==Last[Dimensions[A]]] :=
	With[{n = Length[A]}, ( poly /.
		b_^c_ -> MatrixPower[b, c] /.
   		b_+c___ /; FreeQ[b, x] ->
			HoldForm[b*IdentityMatrix[n] + c] /.
		x -> A ) //ReleaseHold ]

A:= {{2, 2}, {1, 3}};
matp[x^3 + 5*x^2 + 2*x + 3, x][A]

	{{59, 96}, {48, 107}}

...which beats typing in this:

MatrixPower[A, 3] + 5MatrixPower[A, 2] + 2A + 3IdentityMatrix[2]

	{{59, 96}, {48, 107}}


-----
Selwyn Hollis
http://www.math.armstrong.edu/faculty/hollis

On Wednesday, August 13, 2003, at 07:49  AM, Lot-o-fun wrote:

> How do I compute p(A), where p is a polynomial and A is a matrix?
>
> For example, if
>
> p[x_] := x^2 - 3x + 2
>
> and
>
> A = {{1,2},{3,4}}, then I want to compute
>
> p(A) = A^2 - 3A + 2I = {{6,4},{6,12}}
>
> Is there some way of doing this?
>
> I'd also like to be able to do various matrix computations over finite
> fields.  For example, I'd like to compute the minimal polynomial of a
> matrix over Z_2.
>
> Thanks!
>
> -Lotofun
>
>


  • Prev by Date: AW: [newbie] can't get the answer
  • Next by Date: Re: von Neumann entropy
  • Previous by thread: Re: Evaluating a polynomial on a matrix; matrix computations over a finite field
  • Next by thread: Re: Evaluating a polynomial on a matrix; matrix computations over a finite field