Search code examples
numberscalculationmaximasimplification

Maxima. How to prevent degree calculations


Is it possible for all calculations in the expression for numbers in a power to be prevented? Perhaps by pre-processing the expression or adding tellsimp rules? Or some other way?

For example, to

distrib (10 ^ 10 * (x + 1)); 

which produces:

1000000000 x + 1000000000

instead issued:

10 ^ 10 * x + 10 ^ 10

And similarly

factor (10 ^ 10 * x + 10 ^ 10);

returned:

10 ^ 10 * (x + 1);

Just as

factor(200);
2^3*5^2

represents power of numbers, only permanently?


Solution

  • Interesting question, although I don't see a good solution. Here's something I tried as an experiment, which is to display integers in factored form. I am working with Maxima 5.44.0 + SBCL.

    (%i1) :lisp (defun integer-formatter (x) ($factor x))
    INTEGER-FORMATTER
    (%i1) :lisp (setf (get 'integer 'formatter) 'integer-formatter)
    INTEGER-FORMATTER
    (%i1) (x + 1000)^3;
                                           3  3 3
    (%o1)                            (x + 2  5 )
    (%i2) 10^10*(x + 1);
                                    2 5  2 5
    (%o2)                         (2    5   ) (x + 1)
    

    This is only a modification of the display; the internal representation is just a single integer.

    (%i3) :lisp $%
    ((MTIMES SIMP) 10000000000 ((MPLUS SIMP) 1 $X))
    

    That seems kind of clumsy, since e.g. 2^(2*5)*5^(2*5) isn't really more comprehensible than 10000000000.

    A separate question is whether the arithmetic on 10^10 could be suppressed, so it actually stays as 10^10 and isn't represented internally as 10000000000. I'm pretty sure that would be difficult. Unfortunately Maxima is not too good with retracting identities which are applied, particularly with the built-in identities which are applied to perform arithmetic and other operations.