8
$\begingroup$

I would like to have abstract matrices M and S to get out the coefficients of matrix power series however it treats M and S as numbers even if i checked that M.S - S.M != 0. I attach my code below:

$Assumptions = {Element[M, Matrices[{3, 3}]], Element[S, Matrices[{3, 3}]]}
Series[Simplify[(1 - a*(M + S))^(-1)], {a, 0, 3}]

How can i cure this to get out proper result?

Thanks in advance for reply.

$\endgroup$

3 Answers 3

9
$\begingroup$

Be explicit and do it in two steps. The first step is just the series computation with the matrix expression M+S replaced by a single variable:

f = Series[(1 + t x)^(-1), {t, 0, 3}]

$1-x t+x^2 t^2-x^3 t^3+O[t]^4$

We need to describe how to expand powers of x. This can be done recursively:

power[a_, n_Integer] /; n > 1 := Distribute[a . power[a, n - 1]];
power[a_, 1] := a;

After a power is expanded, we also need to collect sequences of like terms into (matrix) powers. This solution does it explicitly by post-processing the result of Split applied to such a sequence:

collect[a__] := With[{l = Power[First[#], Length[#]] & /@ Split[{a}]},
   If[Length@l == 1, First@l, Dot @@ l]];

Apply these rules to the series, remembering also to expand x itself when not wrapped inside Power:

f /. {Power[x, n_] :> power[m + s, n], x -> m + s} /. Dot[a__] :> Dot[collect[a]]

$(1+(-m-s) t+(m.m+m.s+s.m+s.s) t^2+ \\ (-m.m.m-m.m.s-m.s.m-m.s.s-s.m.m-s.m.s-s.s.m-s.s.s) t^3+ \\ O[t]^4)$

For some reason the second replacement does not work (MMA 8.0). It appears to work with almost any head except Dot! Here's a workaround:

f /. {Power[x, n_] :> power[m + s, n], x -> m + s} /.  x_[a__] /; x === Dot :> x[collect[a]]

$1+(-m-s) t+(m^2+s^2+m.s+s.m) t^2+ \\ (-m^3-s^3-m.s^2-m^2.s-s.m^2-s^2.m-m.s.m-s.m.s) t^3+O[t]^4$

$\endgroup$
3
  • 2
    $\begingroup$ This approach will not work on series in which negative powers appear (such as Series[WeierstrassP[t x, {g2, g3}], {t, 0, 1}]), nor should it be expected to: there is no general way to expand negative powers of $m+s$. $\endgroup$
    – whuber
    Commented Apr 26, 2013 at 14:24
  • 4
    $\begingroup$ That's because Dot[a__] evaluates to a__, try with HoldPattern@Dot[a__] $\endgroup$
    – Rojo
    Commented Apr 26, 2013 at 14:29
  • 1
    $\begingroup$ @Rojo Thank you! I was hoping some expert would explain this one. $\endgroup$
    – whuber
    Commented Apr 26, 2013 at 14:33
9
$\begingroup$

There is a new function as of version 9 :

Series[MatrixFunction[(1 - a*(#))^(-1) &, bigM + bigS], {a, 0, 3}] 

output

While the output does not look very pretty it will behave correctly.

$\endgroup$
4
  • $\begingroup$ Trying to get your result explicitly with it - no luck so far. $\endgroup$ Commented Apr 26, 2013 at 14:33
  • $\begingroup$ Yep, definitely not pretty. But, it works. $\endgroup$
    – rcollyer
    Commented Apr 26, 2013 at 14:33
  • $\begingroup$ Re "not look very pretty": What exactly does it look like? $\endgroup$
    – whuber
    Commented Apr 26, 2013 at 14:34
  • 3
    $\begingroup$ @whuber Added the output (rated PG). $\endgroup$ Commented Apr 26, 2013 at 14:37
5
$\begingroup$

Is

$$\begin{split} 1+&(M+S) \, a\\ +&(M\cdot S+S\cdot M+M\cdot M+S\cdot S) \, a^2\\ +&(M\cdot M\cdot S+M\cdot S\cdot M+M\cdot S\cdot S\\ &+S\cdot M\cdot M+S\cdot M\cdot S+S\cdot S\cdot M+M\cdot M\cdot M+S\cdot S\cdot S) \, a^3\\ +&O\left(a^4\right) \end{split}$$

what you're expecting for? If yes, please continue read.

First we define a temporary matrix $A$:

A /: Times[A, A] := CircleTimes[A, A]
A /: Power[A, n_ /; IntegerQ[n] && Positive[n]] := CircleTimes @@ ConstantArray[A, n]
A /: Times[A, CircleTimes[M__]] := CircleTimes[A, M]
A /: Times[CircleTimes[M__], A] := CircleTimes[M, A]

Then we substitute $M+S$ with $A$ and expand the series as normal way:

tempSeries = Series[1/(1 - a  A), {a, 0, 3}]

$1+A\, a+A\otimes A\, a^2+A\otimes A\otimes A\,a^3+O\left(a^4\right)$

Then substitute $M+S$ back and do some replacement and transformation like Distribute etc.

tempSeries /. A -> M + S /.
  CircleTimes[M__] :> Distribute[CircleTimes[M]] /.
 CircleTimes -> Dot

Now we get the result shown at beginning.

$\endgroup$
1
  • $\begingroup$ @grelade You are welcome. $\endgroup$
    – Silvia
    Commented Apr 26, 2013 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.