Hello dear community !
Results of sign function in the attached worksheet are quite tricky.
When calculations for a root under the argument of sign function are done only with integers the result is always like expected, i. e. 0 ?
Why this behavior ? Binary representation of numbers in numeric engine of Mcd...? I'd have wished a more consistent implementation of sign function, for example in agreement with the precision given by TOL or of the symbolic calculus (like in Mcd2001), or without differences between integers and rational (real) numbers...
Same behavior in Mcd Prime ?
I've used this function for roots testing in a program and I was surprised to discover that thus I missed some, like in the case of p30f in attached, where the output of sign is not 0 (zero), as expected for a root of the polynomial in sign argument.
In order to make sign function work evenly in all cases I added round built-in function, the version with two arguments, the second being -log(TOL). Are there alternatives to this approach, since time execution of my program can become an issue ?
Best regards, Liv.
An old thread is about a similar issue : Problem with sign function - PTC Community
This is not an answer. However I would like to point out that you can choose the following option for a different representation of the results.
You are on the limits of numerical evaluations. Asking for being exact zero when dealing with reals sure is a problem.
You might consider implementing a user defined Sign function:
F.M. & Werner, thank you both for your answers.
Your user defined Sign function, Werner, is surely faster than my use of round & log and I'll switch to it with my program.