3

I have expressions of the type

(-y A.A).(-y A.A).(A x).(A x) (* Example 1 *)

(-y A.A).(-y A.A).(A x) (* Example 2 *)

The number of parenthesis factors can vary, and the number of factors of A in each parenthesis can vary. However, each parenthesis has at least one factor of A.

I want to pull out the constants x and y from these expressions to obtain:

x^2 y^2 A.A.A.A.A.A (* Example 1 *)

x y^2 A.A.A.A.A (* Example 2 *)

What is the best way to go about this? I imagine it's going to be related to that answer, but somehow I can't make it work. It would be really nice if there was a very general way handling these quite usual operations.

Ben
  • 249
  • 1
  • 5

1 Answers1

4

I found out that

TensorExpand[(-y A.A).(-y A.A).(A x).(A x),Assumptions->Element[{x,y},Reals]]

will do the job.

Ben
  • 249
  • 1
  • 5