       Re: Product command with matrices

• To: mathgroup at smc.vnet.net
• Subject: [mg87922] Re: Product command with matrices
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Sat, 19 Apr 2008 23:53:36 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <fu9ft7\$ce2\$1@smc.vnet.net>

```J Davis wrote:

> I want to define a matrix valued function such as the following (in
> LaTeX lingo):
>
> \$\$
> X(0)=Id,
> X(n)=\prod_{i=0}^{n-1} (Id + f[i] A)
> \$\$
>
> where A and f have already been defined and Id is the identity matrix
> of appropriate size.
>
> I tried the following:
>
> Id=IdentityMatrix;
> Phi:=Id;
> Phi[n_]:= Product[Id + f[i] A,{i,0,n-1}]
>
> However, Phi and (Id+fA).(Id+fA).(Id+fA) do not agree.

The following will do the recursion and correctly handle the *matrix*
product (which Product[] does not do).

Fold[(Id + f[#2] A).#1 &, Id + f A, Range[n - 1]]

Here is an example of a complete definition:

Id = IdentityMatrix;

phi := Id;
phi[n_] := Fold[(Id + f[#2] A).#1 &, Id + f A, Range[n - 1]]

phi
% == (Id + f A).(Id + f A).(Id + f A) // Simplify

{{A (A (1 + A f) f + A f (1 + A f)) f[
2] + (A^2 f f + (1 + A f) (1 + A f)) (1 + A f),
A (A^2 f f + (1 + A f) (1 + A f)) f[
2] + (A (1 + A f) f + A f (1 + A f)) (1 +
A f)}, {A (A^2 f f + (1 + A f) (1 + A f)) f[
2] + (A (1 + A f) f + A f (1 + A f)) (1 + A f),
A (A (1 + A f) f + A f (1 + A f)) f[
2] + (A^2 f f + (1 + A f) (1 + A f)) (1 + A f)}}

True

Regards,
-- Jean-Marc

```

• Prev by Date: Re: A Problem with Simplify
• Next by Date: Fw: Re: DifferenitalD vs CapitalDifferenitalD
• Previous by thread: Re: Product command with matrices
• Next by thread: Re: Re: Product command with matrices