Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
Every function, which is called with an argument of NaN should deliver NaN as a result !
Some functions deliver odd values such as log, ln, or ln0. Very problematic are the functions min and max which deliver min(NaN)=0 and max(NaN)=0. This can lead to incorrect results, as it was the case in our calculations. This error occured with Prime 8.
Prime 9 also.
So, we should do.
But, if then also
@ttokoro wrote:
So, we should do.
This does not help much as it still fails if NaN is the first entry of the vector!
Sorry to say, but this is behaviour as designed; according to the Help information on NaN in "About the NaN (Not a Number) Built-In Constant":
"... A NaN can only be processed by functions specifically written to use it. Other functions may return errors or incorrect results if passed a NaN."
After all, it's PTC sofware.
Mathcad 11 gives:
Success!
Luc
Hi Luc,
did you try this on Prime8:
Manfred
The bug (or unexpected and undesired result, as its behavior according to the help) with "min" and "max" is already present in Mathcad, so we can blame PTC only for not fixing it.
What we can blame PTC for is for making it even worse as your example with the logs showed
I am surprised that the imaginary part is pi. Would expect at least an integer multiple of 2 pi !?
Here is the same in MC15
Here is something "nice", too
Note that NaNi and also the number in the exponent are labeled as "Unit" ????
In MC15 this still was OK
Even though the help states that using functions on NaN may give wrong results, you may consider opening a ticket at PTC support and report this bug and/or demand that this undesirable behavior should be changed.
Using vector M, Edit: Without NaN fix.
Which results do you get when you use a vector without any NaN's? 😉
EDIT: AH, I see that you have editted your post and fixed your functions to deal correctly with that case 😄
I would expect that min() or max() filters out the NaN and calculates then min/max from the rest. If there is no value left (all values are NaN) then the result should be NaN. I tried several combinations and it seems to depend on the sign and position of NaNs:
It looks as though it checks vectors on NaN's only for the first element, and when found, the NaN is replaced with a 0; scalar NaN in min() and max() is replaced with a 0 as well. NaN's appearing elsewhere in the vector are discarded.
Fortunately NaN is retained in other functions, one way or another...
It's a bug.
May be (remotely?) related to the bug in FilterNaN https://community.ptc.com/t5/Mathcad/Prime-bug-with-quot-filterNaN-quot/m-p/882956#M207191
Success!
Luc