Expand takes too long time

33 views
Skip to first unread message

Gihyuk Cho

unread,
Aug 23, 2021, 8:48:43 AM8/23/21
to xAct Tensor Computer Algebra
Hi all,

I am using xAct for arranging thousands of tensorial term. But whenever I use `Expand' command on that (after some replacements), it takes enormous time, as I did experiments it could take more than 20 hours for ~5000 terms. 

So I tried saving the expression as .mx or .dat file , and open it in kernel 2 (not parallel subkernel but the second master kernel (mathematica usually provides two master kernels)), and I expanded it, but it also took a lot of time. But when I saved it as a text file, and expanded it in kernel 2, with the command "ToExpression", it just takes less than one second for Expand.

At first, I suspected that it is because of some xAct's automatic arrangement on indices,. However, even when I use .mx file without xAct package loaded, it also takes long time (I don't know it takes as long as it does with xAct package) . Only when I save it in text file, it takes a second. 

If you have any ideas why this happens, or have some tricks to resolve this, it would be great if you teach me that. Thanks in advance.

Jose

unread,
Aug 23, 2021, 11:48:01 AM8/23/21
to xAct Tensor Computer Algebra
Hi,

My guess is that some xAct definition(s) (either built-in or from your own code) is interfering with the process of expansion. Saving the .mx file with all the data also saves the xAct code (or at least most of it), so the definitions are still there when you load the .mx file. Saving a text file and reading it without xAct is faster because you don't have those problematic definitions.

But I cannot say much else without having more information about your expression.

The Flat, OneIdentity and Orderless attributes of Plus and Times sometimes make large expressions (with many summands or factors) difficult to handle in pattern matching. In such cases, if possible, it is usually better to have lists of terms, canonicalize them individually and then reconstruct the final expression.

Cheers,
Jose.
Reply all
Reply to author
Forward
0 new messages