4
$\begingroup$

I am attempting a perturbation expansion in Mathematica. As part of this, I would like to expand a matrix-vector product where the vectors are given in powers of epsilon. Eventually, I'd like to generate a CoefficientList in powers of epsilon of something like

$Assumptions=Q ∈ Vectors[3] && P ∈ Vectors[3] && A ∈ Matrices[{3, 3}];
A . (P ϵ + Q ϵ^2)

But first I would like to expand the second expression as

ϵ A.P + ϵ^2 A.Q

but mathematica doesn't seem to want to expand it. I thought that specifying $A$, $P$, and $Q$ as Matrices and Vectors but so far it hasn't been helpful.

I've looked at this question and this one, which come close to what I'm asking.

Eventually, I would like to be able to substitute in a particular matrix for $A$ but I think that while generating the sequence of equations at different orders in $\epsilon$ it makes more sense to leave it unspecified.

$\endgroup$
0

1 Answer 1

6
$\begingroup$

Use TensorExpand:

$Assumptions = Q ∈ Vectors[3] && P ∈ Vectors[3] && A ∈ Matrices[{3, 3}];
TensorExpand[A . (P ϵ + Q ϵ^2)]

ϵ A . P + ϵ^2 A . Q

$\endgroup$
1
  • $\begingroup$ (+1) from me. Carl, do you know why Distribute does not work nicely even with an assumption on ε? The only reason I am asking is because TensorExpand[A.(P + A)] gives as output A.P + MatrixPower[A, 2] whilst Distribute[A.(P + A)] returns the more natural A.A + A.P. $\endgroup$
    – bmf
    Commented Apr 26, 2022 at 0:38

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.