* Experiments suggest that negation (or equivalently a factor -1) is the
only factor that Maxima unavoidably distributes over a sum by default
simplification ("evaluation").
* Mathematica goes slightly further by also distributing (only) the -1 out
of a negative rational number, such as
(-1/2)*(x+1) --> (-x - 1)/2 .
* Maple goes even further by distributing any entire number, including a
Float, regardless of sign.
* Perhaps these exceptions to their general policies of no default
distribution were motivated by examples such as
x - (x - 1)
not otherwise automatically simplifying to 1 .
* However, it is better not to do the distribution unless something is
added to the negated sum that could cause cancelations such as in this
example.
* In fact, it is better to factor out a unit to make a sum unit normal when
it is multiplied by something or raised to an exponent. This enables the
automatic simplifications
2(x + 1) + 2(-x - 1) --> 0,
(a + b + ... + z)*(-a - b - ... - z) --> -(a + b + ... + z)^2,
and
(x + 1)^2 - (-x - 1)^2 --> 0 .
* Unit normalization in the context of a power or a product is also
beneficial for sums having complex numeric coefficients, as described in
ACM Communications in Computer Algebra 43 (3), September 2009, pp. 73-76.
(The idea is to factor out the unit -1, %i, or -%i if necessary to make the
(recursively defined) leading numeric coefficient c have -%pi/4 < arg(c)
<= %pi/4.)
* (Actually, it is beneficial also to do modest default context-dependent
distribution or factoring out of syntactic content as described in Journal
of Symbolic Computation Volume 46, Issue
7<http://www.sciencedirect.com/science/journal/07477171/46/7>,
July 2011, Pages 859?887. However, implementing that is a major project in
comparison to just making sums unit normal when they occur as the base of a
power or as a factor in a product.)
-- best regards, david stoutemyer
On Fri, Nov 2, 2012 at 12:50 PM, Stavros Macrakis <macrakis at alum.mit.edu>wrote:
> Just noticed this very trivial case:
>
> -(x+1)*(x+1) => (-x-1)*(x+1) rather than -(x+1)^2
>
> This is because -(x+1) => -x-1, and the expression is parsed as
> (-(x+1))*(x+1) rather than as -((x+1)*(x+1)).
>
> Of course, the workaround is simply factor(...), but I wonder if others
> find this annoying, and whether it is fixable without messing up other
> cases....
>
> -s
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>