Re: Help for Symbolic matrix manipulations in mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg26099] Re: [mg26069] Help for Symbolic matrix manipulations in mathematica?
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Tue, 28 Nov 2000 01:55:42 -0500 (EST)
- References: <200011220655.BAA19975@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Louis Trichard wrote:
>
> Hi
>
> I'm quite new to mathematica and not sure on where to start.
>
> What I would like to do is to initially symbolically manipulate
> matrices.
>
> i.e. find the coefficients of (R+X)^i where R and X do not
> commute...ie. binomial theorem does not apply.
>
> for example (R+X)^2 = R^2 + RX + XR + X^2 **********1
>
> then simplify the expression s^t (R + X)^i s where X = s s^t and
> s^t s = 1 where t indicates transpose and s is a vector.
>
> for example **********1 will simplify to
>
> s^t (R+X)^2 s = s^t R^2 s + s^t RX s + s^t XR s + s^t X^2 s
> = s^t R^2 s + 2 s^t R s +
> 1 , where s^t X = s and so forth....
>
> of course this looks like just an application of the binomial
> theorem but for i=3 we get....
>
> s^t (R+X)^3 s = s^t R^3 s + 2 s^t R^2 s + (s^t R s)^2 + 3 s^t R s +
> 1....
>
> So I would like to have a program which can give me the coefficients
> etc for an arbitrary i...
>
> Can mathematica do it, if so, could someone point me in the right
> direction to do such a thing...
>
> Thanks
>
> Louis
There might be more efficient approaches, but you could put rules on
NonCommutativeMultiply, define expansion of noncommutative products that
possibly involve sums, and interleave simplification rules. For example:
simprules = {
NonCommutativeMultiply[a___,x_?NumberQ,b___] ->
x*NonCommutativeMultiply[a,b],
(NonCommutativeMultiply[a___,x_^m_.,x_^n_.,b___]/;Head[x]=!=Plus) ->
NonCommutativeMultiply[a,x^(m+n),b],
X^n_ -> X, Transpose[s]**s -> 1,
Transpose[s]**X^n_. -> Transpose[s], X^n_.**s -> s,
NonCommutativeMultiply[a_] -> a
};
ncExpandPower[sum_,0] = 1;
ncExpandPower[sum_,1] := sum
ncExpandPower[sum_,2] := ncExpandProduct[sum,sum]
ncExpandPower[sum_,n_Integer /; n>2] :=
ncExpandProduct[ncExpandPower[sum,n-1],sum] //. simprules
ncExpandProduct[s1_,s2_] :=
Distribute[NonCommutativeMultiply[s1,s2]] //. simprules
ncExpandProduct[s1_,s2_,s3__] :=
ncExpandProduct[ncExpandProduct[s1,s2],s3]
Here are some simple examples along the lines of your example.
In[122]:= InputForm[ncExpandProduct[Transpose[s],
ncExpandPower[(R+X),3], s]]
Out[122]//InputForm=
1 + 3*Transpose[s]**R**s + 2*Transpose[s]**R^2**s + Transpose[s]**R^3**s
+
Transpose[s]**R**X**R**s
In[123]:= InputForm[ncExpandProduct[Transpose[s],
ncExpandPower[(R+X),5], s]]
Out[123]//InputForm=
1 + 5*Transpose[s]**R**s + 4*Transpose[s]**R^2**s +
3*Transpose[s]**R^3**s +
2*Transpose[s]**R^4**s + Transpose[s]**R^5**s +
3*Transpose[s]**R**X**R**s +
2*Transpose[s]**R**X**R^2**s + Transpose[s]**R**X**R^3**s +
2*Transpose[s]**R**X^2**R**s + Transpose[s]**R**X^2**R^2**s +
Transpose[s]**R**X^3**R**s + 2*Transpose[s]**R^2**X**R**s +
Transpose[s]**R^2**X**R^2**s + Transpose[s]**R^2**X^2**R**s +
Transpose[s]**R^3**X**R**s + Transpose[s]**R**X**R**X**R**s
A symbolic form of rank-1 updates?
Daniel Lichtblau
Wolfram Research
- References:
- Help for Symbolic matrix manipulations in mathematica?
- From: Louis Trichard <trich-lg@ee.usyd.edu.au>
- Help for Symbolic matrix manipulations in mathematica?