vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
982 stars 118 forks source link

non-commuting functions, denominators, and brackets #466

Open jmbrod opened 5 months ago

jmbrod commented 5 months ago

Hello, just a quick question (not very urgent). Is there a reason that fractions of e.g. symbols are pulled out of a bracket if they are to the left a non-commuting function that is bracketed? I.e. it seems that denom_ is internally always treated as non-commuting (why)?

As a simple example, this code

s x1,x2;
f fun;

l exp1 = fun(x1) + 1/(x1-x2) * fun(x1);

b fun;

print +s;
.end

gives two terms in the final result:

   exp1 =

       + 1/( - x2 + x1)*fun(x1) * (
          + 1
          )

       + fun(x1) * (
          + 1
          );

This does not happen if fun is commuting, or if in my expression I have the denominator to the right of fun, or if the symbols appear only in a numerator.

Just curious -- thanks for any comments!

vermaseren commented 5 months ago

The problem here is that using the 1/(…) is a built-in function that is not very powerful. To begin with, it is only simplified in the simplest of cases. And Form does not look inside it, once it is not simple. Hence it does not know whether the content is commuting or not. Therefore it has to assume that it is non-commuting. Basically this function is tolerated, but you are far better off to define your own denominator function like den(x1-x2) stands for 1/(x1-x2). In that case you can decide yourself whether it is commuting. Also, in that case, all rules of pattern matching apply. The 1/(x1-x2) variety cannot do much with pattern matching and other operations on functions.

On 18 Jan 2024, at 17:34, Joachim Brod @.***> wrote:

Hello, just a quick question (not very urgent). Is there a reason that fractions of e.g. symbols are pulled out of a bracket if they are to the left a non-commuting function that is bracketed? I.e. it seems that denom_ is internally always treated as non-commuting (why)?

As a simple example, this code

s x1,x2; f fun;

l exp1 = fun(x1) + 1/(x1-x2) * fun(x1);

b fun;

print +s; .end gives two terms in the final result:

exp1 =

   + 1/( - x2 + x1)*fun(x1) * (
      + 1
      )

   + fun(x1) * (
      + 1
      );

This does not happen if fun is commuting, or if in my expression I have the denominator to the right of fun.

Just curious -- thanks for any comments!

— Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/466, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJPCEWEJNEXJIKTWS2KQZTYPFFLFAVCNFSM6AAAAABCASONEGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA4DQNRVHE2DAMQ. You are receiving this because you are subscribed to this thread.

jmbrod commented 5 months ago

OK, thanks for the quick clarification and the advice!