Work on the simplifier: TMS and TIMESIN



Am Montag, den 01.06.2009, 14:20 -0400 schrieb Richard Fateman:
> I am traveling and can't look at this in detail, but I suspect there
> is a lurking inconsistency in this processing which will be revealed
> if you have to factor expressions, which would be too expensive to do,
> generally.  e.g.  p*q*q^(1/2)  is   p*q^(3/2),  but what if p and q
> are huge prime integers?

Hello Richard,

The code as it is, does the following:

2*2^k   --> 2^(k+1)
2*2*2^k --> 2^(k+2)
...

2^k*2   --> 2^(k+1)
...

but has trouble, when a symbol is involved:

2*a*2^k  --> 2*a*2^k , no simplification to a*2^(k+1)

Another problem is, that the simplification is not associative:

sqrt(2)/2   --> 1/sqrt(2)
1/2*sqrt(2) --> sqrt(2)/2, no simplification 

2/sqrt(2)   --> 2/sqrt(2), no simplification
1/sqrt(2)*2 --> sqrt(2)

To do the above simplifications we have code in TMS and in TIMESIN to
handle numbers. Apparently, the code does not work consistent.

A second problem of the code is, that for a number q we first scan the
whole list of factors in the routine TMS to look for a facor q^k. Later
in TIMESIN we again go through the list of factors.


The proposed changes to TMS and TIMESIN do not really extent the ideas
of what we have, but will do all examples from above in a consistent
way.

The main idea is to do no special handling of numbers in TMS, but handle
them like other symbols in TIMESIN. Therefore, we do not multiply the
numbers "away" in TMS, but go into TIMESIN with the number and look for
the desired simplifications. At this place we can implement these
simplifications in a consistent way. Furthermore, because we already go
through the list of factors, I think, this way is also more efficient. 

To get the above examples consistent with the existing code, which
shares the functionality between TMS and TIMESIN, we would have to
double a lot of code and perhaps it is not possible to get it
consistent.

By the way I have found a further inconsistency:

2*3*6*2^k*3^k --> 3^(k+2)*2^(k+2)  but
2^k*3^k*2*3*6 --> (3*2^(k+2))*3^(k+1)

The last expression is in addition not fully simplified (a simp flag is
missing). This causes the extra parentheses. Unfortunately, the proposed
changes up to now have problems with this last expression too.

Dieter Kaiser