3
$\begingroup$

Why doesn't Simplify and FullSimplify operate on object generated using SymmetrizedArray?

For example:

FullSimplify[SymmetrizedArray[metric.riemann, {n, n, n, n}, Antisymmetric[{3, 4}]  

leaves expressions like 1/2*(-2a'[t]^2+2a[t]*a''[t]) without obvious simplification of factors 2.

More transparent example: (FullSimplify acting on structured array and on normal array)

In:

AA = SymmetrizedArray[{{1, 2} -> (a^2 - b^2)^3, {1, 3} -> ((a-b) (a + b))^3, {2, 3} -> x}, {3, 3}, Antisymmetric[{1, 2}]];
B1 = Normal[FullSimplify[AA]]
B2 = FullSimplify[Normal[AA]]

Out:

{{0,(a^2-b^2)^3,(a-b)^3 (a+b)^3},{-(a^2-b^2)^3,0,x},{-(a-b)^3 (a+b)^3,-x,0}}
{{0,(a^2-b^2)^3,(a^2-b^2)^3},{-(a^2-b^2)^3,0,x},{-(a^2-b^2)^3,-x,0}}

Of course my expressions are much more complicated and time consuming. I can't do it by transforming a structured array to normal form, because it is better to do operations (in this case simplification) only on independent components (in order to economize computing time and memory).

Perhaps I should use Map, but I don't understand how it works with a structured array.

Any suggestions ?

$\endgroup$
4
$\begingroup$

You main problem here is that a SymmetrizedArray is not an expression once you have constructed it. It is an atom, a raw object that (although it looks otherwise) cannot be decomposed into smaller expressions

AA = SymmetrizedArray[{{1, 2} -> (a^2 - b^2)^3, 
  {1, 3} -> ((a - b) (a + b))^3, {2, 3} -> x}, {3, 3}, 
  Antisymmetric[{1, 2}]];
AtomQ[AA]

(* True *)

This means, although it looks like it is a composed expression

InputForm[AA]
(* StructuredArray[SymmetrizedArray, {3, 3}, StructuredArray`StructuredData[
  SymmetrizedArray, {{1, 2} -> (a^2 - b^2)^3, 
   {1, 3} -> (a - b)^3*(a + b)^3, {2, 3} -> x}, Antisymmetric[{1, 2}]]] *)

You cannot take parts of it and e.g. AA[[1]] doesn't work. Neither does replacing or (as you planned) mapping a function over it work.

The only possible solution I see is to simplify your expressions before you build your structured array.

$\endgroup$
  • 2
    $\begingroup$ This is an explanation why it works in unexpected way. Thank you. Nevertheless, I realize that there is a certain solution and way to reach the goal. At first it is convenient to summarize the problem in simple form: "take a StructuredArray (with some symmetry) -> do a simplification only on independant components -> return simplified StructuredArray with respective symmetries". And that is a solution: BB = SymmetrizedArray[ FullSimplify[SymmetrizedArrayRules[AA]], TensorDimensions[AA], TensorSymmetry[AA]]. $\endgroup$ – Druid Apr 16 '15 at 9:58
  • 2
    $\begingroup$ Moreover this code have another advantage: it may be effectively parallelized: BB = SymmetrizedArray[ParallelMap[FullSimplify,SymmetrizedArrayRules[AA],{1}], TensorDimensions[AA], TensorSymmetry[AA]]. There is no problem with parallel processing of deeper levels of table/array, because already they are all in form of list of rules. $\endgroup$ – Druid Apr 16 '15 at 10:05
  • $\begingroup$ Right and it is exactly what I meant by * simplify your expressions before you build your structured array*. Btw, please verify carefully whether the ParallelMap is really faster than simply calling FullSimplify on the complete expression. $\endgroup$ – halirutan Apr 16 '15 at 10:59
  • $\begingroup$ @Druid Thanks for the very handy function you came up with to simplify structured arrays. I use it so much that I set up two buttons for it (one to Simplify and one to FullSimplify) in a custom palette for working with tensors. I have referred to your function in the asked and answered question 'Conveniently solving tensor equations in which the contained tensors have various symmetries' (link). $\endgroup$ – Bill N Dec 6 '16 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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