[Maxima] Absolute value of the Log function

Dieter Kaiser drdieterkaiser at web.de
Sat Aug 22 14:38:25 CDT 2009

```I have reported some problems with the limit of the factorial and log
functions. Furthermore I think we have a problem with the absolute value
of the log function.

I have got step by step the code to get correct answers, but finally I
had a problem with the following example

(%i3) limit(abs(log(x)),x,0);
(%o3) inf

This example does not simplify to inf after improving simplimln and the
absolute value of the Log function.

Furthermore I have observed the following strange answers of the current
Maxima code:

The following limit does not work as expected:

(%i2) limit(abs(x),x,infinity);
(%o2) -(infinity^2-inf^2)/inf

And

(%i10) limit(abs(x+infinity),x,0);
sign: sign of infinity is undefined.
-- an error.  To debug this try debugmode(true);

We get the limit from below and above:

(%i4) limit(abs(x),x,infinity,plus);
(%o4) infinity
(%i5) limit(abs(x),x,infinity,minus);
(%o5) infinity

But I think in all cases the correct answer should be inf.

The failure to get the limit of abs(log(x)) as x-> 0 after improving
simplimln and the absolute value of the Log function shows a special
problem in the routine \$limit.

After preparing the expression and setting the context we do the
following resimplification in the routine \$limit:

;; Resimplify in light of new assumptions.
(setq exp
(resimplify
(factosimp
(tansc
(lfibtophi
(limitsimp (\$expand (hide exp) 1 0) var))))))

The problem is, that in special situations this code simplifies the Abs
function away. This is e.g. the case for the simple example
limit(abs(x),x,infinity). Maxima now calculates the limit of the
argument of the Abs function, but lost the information to take the
absolute value after getting the limit of the argument. This causes
problems when an infinity is involved in the limit.

In the case limit(abs(log(x)),x,0) Maxima simplifies to -log(x). Again
the information to take the absolute value is simplified away.

I think we actually get some correct results by accident. If we change
the following limit to

(%i33) limit(log(x),x,0,minus);
(%o33) infinity

and correct the wrong simplification of log(x) -> -log(x) the limit of
abs(log(x)) -> 0 no longer works, because of the problem in \$limit.

I have added the following code to the routine \$limit just before we do
the resimplifcation.

;; Try to find the limit and sign of the argument of the
;; Abs function before doing any other simplification.
(if (and (not (atom exp)) (eq (caar exp) 'mabs))
(let* ((arg (\$limit (cadr exp) var val))
(sgn (\$sign arg)))
(setq exp
(cond ((eq arg '\$infinity)
'\$inf)
((eq sgn '\$neg)
(mul -1 arg))
((member sgn '(\$pos \$pz))
arg)
(t exp)))))

With this code all works fine. We get the expected limits and the
answers are really simplified. Here the discussed examples:

(%i34) limit(abs(x),x,infinity);
(%o34) inf
(%i35) limit(abs(x+infinity),x,0);
(%o35) inf
(%i36) limit(abs(log(x)),x,0);
(%o36) inf

Remark:

Finally one example of the testsuite will fail

integrate(1/x,x,minf,inf) no longer give the answer 0.

but returns a noun form. I think this integral should be divergent and
the example should be marked as an expected failure.

Dieter Kaiser

```