cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

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

How does/should the Is Element Of operator treat NaNs?

StuartBruff
23-Emerald III

How does/should the Is Element Of operator treat NaNs?

Whilst playing around with the Is Element Of operator in Mathcad Express 7, I noticed the following:

 

StuartBruff_0-1637522789270.png

 

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.

 

2021 11 21 H.png

 

2021 11 21 I.png

 

6 REPLIES 6
Werner_E
25-Diamond I
(To:StuartBruff)

Here is how the symbolic processor treats NaN (done in Prime 6) for your information

Werner_E_0-1637533282542.png

 

StuartBruff
23-Emerald III
(To:Werner_E)


@Werner_E wrote:

Here is how the symbolic processor treats NaN (done in Prime 6) for your information

Werner_E_0-1637533282542.png

 


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

Werner_E
25-Diamond I
(To:StuartBruff)


@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

Werner_E_0-1637544559259.png

The "assume" modifier is ignored

Werner_E_1-1637544867660.png

 

 

Werner_E
25-Diamond I
(To:Werner_E)

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_0-1637545535296.png

 

StuartBruff
23-Emerald III
(To:Werner_E)


@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

 

 

Werner_E
25-Diamond I
(To:StuartBruff)


 

And NaN?  😈

 


There very same as with the new symbolics - not evaluated

Announcements

Top Tags