Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Whilst playing around with the Is Element Of operator in Mathcad Express 7, I noticed the following:
I was surprised to see that Mathcad thinks that NaN is a Real (and hence Complex), but not an integer.
Is this just a case where one should expect inconsistent results from applying non-NaN-specific functions to a NaN? If so, I think there should be a warning about this behaviour on the Is Element Of Help page.
Or is it something that should be corrected?
The red error arises because only the symbolic processor can test for rationals and Mathcad Express doesn't have symbolics. Consequently, I don't know whether Is Element Of's NaN behaviour extends to symbolics.
Stuart
I discovered the above whilst trying to write a couple of data type identification functions.
Here is how the symbolic processor treats NaN (done in Prime 6) for your information
@Werner_E wrote:
Here is how the symbolic processor treats NaN (done in Prime 6) for your information
The symbolic processor just returns the expression unevaluated? Strange, I wasn't expecting that. How does it evaluate integer, rational, real & complex numbers and strings & functions?
Stuart
@StuartBruff wrote:
The symbolic processor just returns the expression unevaluated?
Yes, it treats NaN like an unknown variable. There is no difference whether "units/constants in symbolics" is turned on (like in the screenshot) or turned off.
According to numbers the result is as expected, strings are not seen as numbers as it should be and functions ... see yourself. The function name alone is simplifed to "function", otherwise the function is evaluated and we get a result only if its a constant number
The "assume" modifier is ignored
Just for fun and because it can be done in Prime 6 I switched to the legacy symbolic (muPad) and the results ar somewhat irritating.
The error message is something along the line "a floating point approximation cannot be tested for membership in the rational numbers".
@Werner_E wrote:
Just for fun and because it can be done in Prime 6 I switched to the legacy symbolic (muPad) and the results ar somewhat irritating.
The error message is something along the line "a floating point approximation cannot be tested for membership in the rational numbers".
Interesting.
And NaN? 😈
Stuart
And NaN? 😈
There very same as with the new symbolics - not evaluated