Skip to main content
23-Emerald IV
May 22, 2024
Question

BUG: inconsequent behaviour of match() function.

  • May 22, 2024
  • 1 reply
  • 2054 views

Apart from the counter-intuitive behaviour of the match() function (and I suppose this holds also for the lookup functions) as shown here:

LucMeekes_1-1716414145713.png

Due to the definition of z and A, none of the results should change when the value of TOL is changed. However:

LucMeekes_3-1716414817532.png

It seems like the value of TOL does 'influence the precision of the comparison' but in an unclear, unpredictable way.

I would suggest that ONLY the 'fuzzy' descriptor/modifier "near" uses the value of TOL. Then "eq" should be implemented as 'equals exactly' and likewise for "leq", "lt", "gt", "geq" and "not". Then with "range" the comparison should be to the borders set by z exactly, after specifying whether or not the border values are in range or not. Then the description of "near" should not use the word, 'closest', because "near" is supposed to use the implicit range from (1-TOL)*z to (1+TOL)*z, where some values may be found closer to z than others.

I suggest to add an option "nearest" to find the value(s) in A that is/are truely 'closest' to z: all values of A that (exactly) equal min(|A-z|). Then also an option "furthest" for the opposite condition.

 

Success!

Luc

 

 

 

1 reply

25-Diamond I
May 23, 2024

I agree that the behaviour of the match and lookup functions are not the way they should be (and I guess they never were, not even in real Mathcad).

For a 'true' equal you would have to use

Werner_E_0-1716422782850.png

It should not be necessary but generally you are better off defining your own comparison functions

Werner_E_0-1716423466768.png

Because only simple boolean functions with two arguments are allowed I guess its not possible to create a "nearest" functionality.

 

 

19-Tanzanite
May 23, 2024

@Werner_E wrote:

Because only simple boolean functions with two arguments are allowed I guess its not possible to create a "nearest" functionality.


What do you mean by only simple boolean functions with two arguments? Two arguments? Do you mean that its not possible to have for example lt(x,y,z):= x-y-z < -TOL?

LucMeekes23-Emerald IVAuthor
23-Emerald IV
May 23, 2024

Try it.

 

Success!

Luc