Note that csign(atanh(z)) returns complex.
According to the manual, sign cannot return complex. So should sign raise an error when it's guaranteed to be non-real? It does this in the following case:
~~~
(%i1) assume(x<0)$
(%i2) sign(sqrt(x));
sign: argument cannot be imaginary; found sqrt(q)
-- an error. To debug this try: debugmode(true);
~~~
But not for log, not even with an explicit negative argument:
~~~
(%i3) sign(log(-1));
(%o3) pnz
~~~
Last edit: David Scherfgen 3 days ago
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, sign should ideally raise an error when the argument is never real.
But it should return a result when the result is real somewhere. For example, sign(sqrt(sin(x)-1)) => zero (correct), even though it is only real and zero when x is a multiple of %pi.
Now consider sign(%i*x). Maxima gives an error because it is syntactically complex. But it is zero when x=0, so going by the previous example, it too should return zero.
That said, Maxima cannot tell in general whether an expression is everywhere non-real. A simple example is sign(sqrt(-sin(x)^2-cos(x)^2)) => zero. Of course we can fix particular cases like this, but it will never cover all cases.
We can't expect sign to be perfect. Perhaps the manual should be clear that this is a "best effort" function, and in particular that pnz doesn't mean that the value is real, but only that Maxima couldn't determine whether it was real.
It's all a bit messy....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But it should return a result when the result is real somewhere. For example, sign(sqrt(sin(x)-1)) => zero (correct), even though it is only real and zero when x is a multiple of %pi.
Is that really how sign is supposed to work? The docs kind of hint at that, but I was certainly surprised about that. I don't think anyone would expect zero as the answer either.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Note that
csign(atanh(z))returnscomplex.According to the manual,
signcannot returncomplex. So shouldsignraise an error when it's guaranteed to be non-real? It does this in the following case:~~~
(%i1) assume(x<0)$
(%i2) sign(sqrt(x));
sign: argument cannot be imaginary; found sqrt(q)
-- an error. To debug this try: debugmode(true);
~~~
But not for
log, not even with an explicit negative argument:~~~
(%i3) sign(log(-1));
(%o3) pnz
~~~
Last edit: David Scherfgen 3 days ago
Yes,
signshould ideally raise an error when the argument is never real.But it should return a result when the result is real somewhere. For example,
sign(sqrt(sin(x)-1)) => zero(correct), even though it is only real and zero whenxis a multiple of%pi.Now consider
sign(%i*x). Maxima gives an error because it is syntactically complex. But it is zero when x=0, so going by the previous example, it too should returnzero.That said, Maxima cannot tell in general whether an expression is everywhere non-real. A simple example is
sign(sqrt(-sin(x)^2-cos(x)^2)) => zero. Of course we can fix particular cases like this, but it will never cover all cases.We can't expect
signto be perfect. Perhaps the manual should be clear that this is a "best effort" function, and in particular thatpnzdoesn't mean that the value is real, but only that Maxima couldn't determine whether it was real.It's all a bit messy....
Is that really how
signis supposed to work? The docs kind of hint at that, but I was certainly surprised about that. I don't think anyone would expect zero as the answer either.