Problems with the sqrt function



I have written a testfile rtest_sqrt.mac which should show what a Maxima
user can expect when using the sqrt function. This testfile includes
specific values, values at infinity, general characteristics, series
representations, differential equations, argument simplifications,
nested sqrt expressions, complex characteristics, differentiation,
integration, Laplace transforms and representations through
hypergeometric functions.

I get about 40 expected errors with this testfile.

Because the sqrt function is one of the elementary functions it might be
interesting to look at the reasons for each of these errors. I have
counted four problems in the main simplifying routine simpexpt The first
three problems are responsible for most of the expected errors.

Problem 1: Wrong simplification sqrt(1/z) -> 1/sqrt(z)
           Reported as bug ID: 1010768 - sqrt(1/z) - 1/sqrt(z) => 0

This is a known problem. The simplification is wrong for a negative
argument:

(%i1) assume(xn<0)$

(%i2) sqrt(1/xn)+1/sqrt(xn);
(%o2) 2/sqrt(xn) /* Wrong: expected 0 */


Problem 2: Wrong simplification sqrt(-1/x) -> 1/sqrt(-x)
           Reported as bug ID: 2852992 - sqrt(-1/x)-%i/sqrt(x) not zero

This is a reported bug too. This simplification is wrong for a positive
argument:

(%i3) assume(xp>0)$

(%i7) sqrt(-1/xp);
(%o7) -%i/sqrt(xp) /* Wrong: expected %i/sqrt(xp) */


Problem 3: Wrong simplification sqrt(-z^2) -> %i*sqrt(z^2)

Because of this simplification we always get:

(%i8) sqrt(-z^2)/sqrt(z^2);
(%o8) %i

But this is wrong e.g. for the value %i:

(%i9) sqrt(-%i^2)/sqrt(%i^2);
(%o9) -%i


Problem 4: Wrong simplification sqrt(exp(z)) -> exp(z/2)

We always get:

(%i10) sqrt(exp(z));
(%o10) %e^(z/2)

The following shows that this is wrong for z=2*%pi*%i:

(%i13) exp(2*%pi*%i/2) - sqrt(exp(2*%pi*%i));
(%o13) -2


The problems 1 and 2 are already reported bugs. The problems 3 and 4 are
not reported. 

We have the functions radcan and rootscontract to simplify expression
with the sqrt function. Both functions have some problems too which
seems to be not related to the simplifier. But it is more easy to try to
correct at first the simplifier, because the algorithm of the functions
radcan and rootscontract might depend on corrections of simpexpt.

I have already reported some work to overcome some of the problems.
Perhaps it is of interest to go on and to start to correct the problems
step by step. Perhaps it of interest to add the file rtest_sqrt.mac to
the testsuite too.

Dieter Kaiser