<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic BUG: inconsequent behaviour of match() function. in Mathcad</title>
    <link>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951606#M212007</link>
    <description>&lt;P&gt;Apart from the counter-intuitive behaviour of the match() function (and I suppose this holds also for the lookup functions) as shown here:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LucMeekes_1-1716414145713.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104866i5B2BCC1E2A735AF9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LucMeekes_1-1716414145713.png" alt="LucMeekes_1-1716414145713.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Due to the definition of z and A, none of the results should change when the value of TOL is changed. However:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LucMeekes_3-1716414817532.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104868i14102739DFC63BF4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LucMeekes_3-1716414817532.png" alt="LucMeekes_3-1716414817532.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It seems like the value of TOL does 'influence the precision of the comparison' but in an unclear, unpredictable way.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Success!&lt;/P&gt;
&lt;P&gt;Luc&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 May 2024 22:11:39 GMT</pubDate>
    <dc:creator>LucMeekes</dc:creator>
    <dc:date>2024-05-22T22:11:39Z</dc:date>
    <item>
      <title>BUG: inconsequent behaviour of match() function.</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951606#M212007</link>
      <description>&lt;P&gt;Apart from the counter-intuitive behaviour of the match() function (and I suppose this holds also for the lookup functions) as shown here:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LucMeekes_1-1716414145713.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104866i5B2BCC1E2A735AF9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LucMeekes_1-1716414145713.png" alt="LucMeekes_1-1716414145713.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Due to the definition of z and A, none of the results should change when the value of TOL is changed. However:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LucMeekes_3-1716414817532.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104868i14102739DFC63BF4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LucMeekes_3-1716414817532.png" alt="LucMeekes_3-1716414817532.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It seems like the value of TOL does 'influence the precision of the comparison' but in an unclear, unpredictable way.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Success!&lt;/P&gt;
&lt;P&gt;Luc&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 22:11:39 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951606#M212007</guid>
      <dc:creator>LucMeekes</dc:creator>
      <dc:date>2024-05-22T22:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: BUG: inconsequent behaviour of match() function.</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951614#M212008</link>
      <description>&lt;P&gt;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).&lt;/P&gt;
&lt;P&gt;For a 'true' equal you would have to use&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_0-1716422782850.png" style="width: 307px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104874i050F80E2AE0F9951/image-dimensions/307x125?v=v2" width="307" height="125" role="button" title="Werner_E_0-1716422782850.png" alt="Werner_E_0-1716422782850.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It should not be necessary but generally you are better off defining your own comparison functions&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_0-1716423466768.png" style="width: 507px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104875i9373375C8B40CC0F/image-dimensions/507x252?v=v2" width="507" height="252" role="button" title="Werner_E_0-1716423466768.png" alt="Werner_E_0-1716423466768.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Because only simple boolean functions with two arguments are allowed I guess its not possible to create a "nearest" functionality.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 00:21:48 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951614#M212008</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2024-05-23T00:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: BUG: inconsequent behaviour of match() function.</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951661#M212011</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/66934"&gt;@Werner_E&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;Because only simple boolean functions with two arguments are allowed I guess its not possible to create a "nearest" functionality.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;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 &amp;lt; -TOL?&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 06:44:12 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951661#M212011</guid>
      <dc:creator>Cornel</dc:creator>
      <dc:date>2024-05-23T06:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: BUG: inconsequent behaviour of match() function.</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951684#M212012</link>
      <description>&lt;P&gt;Try it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Success!&lt;/P&gt;
&lt;P&gt;Luc&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 07:47:55 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951684#M212012</guid>
      <dc:creator>LucMeekes</dc:creator>
      <dc:date>2024-05-23T07:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: BUG: inconsequent behaviour of match() function.</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951693#M212013</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/300363"&gt;@Cornel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/66934"&gt;@Werner_E&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;Because only simple boolean functions with two arguments are allowed I guess its not possible to create a "nearest" functionality.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;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 &amp;lt; -TOL?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Of course thats not allowed! How should "match" handle a function with three arguments?&lt;/P&gt;
&lt;P&gt;Why don't you look it up in the help, it clearly says&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Werner_E_0-1716449535819.png" style="width: 999px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104901i8BD218603FC97EFA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Werner_E_0-1716449535819.png" alt="Werner_E_0-1716449535819.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It looks to me that the example is not really clever chosen as it should rather read 10% b and not 10% z - so you don't have to edit the function just because you want to use a different value for the first argument of "match" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;match" and "lookup" use this function f just to select those values for which f(a,z) returns "true". z is the value you provide as first argument of "match" and a loops&amp;nbsp; through the vector (second function argument). Each element of the vector is treated separately and independent from the others and therefore no "nearest" could be created that way.&lt;/P&gt;
&lt;P&gt;Of course you can write a match_nearest function, but it can't be created using the built-in match function by providing a custom function as last argument,&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_2-1716450649167.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104906iF5B0185B873EC1F7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Werner_E_2-1716450649167.png" alt="Werner_E_2-1716450649167.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Because this function uses 'exact' equality and not that weak "equ" , it may miss values just because tiny round-off errors.&lt;/P&gt;
&lt;P&gt;For example using Lucs vector A (using default TOL=10^3)&amp;nbsp; the following function call should return indices 3 and 4, but index 3 is missing:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_3-1716451010335.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104907i5CF2BF92AA64B109/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Werner_E_3-1716451010335.png" alt="Werner_E_3-1716451010335.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The absolute values of the differences at index 3 and 4 should be equal&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_4-1716451056171.png" style="width: 341px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104908i3E16D4CF4CB67FB7/image-dimensions/341x210?v=v2" width="341" height="210" role="button" title="Werner_E_4-1716451056171.png" alt="Werner_E_4-1716451056171.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But when we look closer we see that the value at index 3 is slightly larger&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_5-1716451100200.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104909i0B7E9C78B475298B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Werner_E_5-1716451100200.png" alt="Werner_E_5-1716451100200.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The usual workaround is not to ask for exact equality but rather for approximate equal within a certain tolerance&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_6-1716451180771.png" style="width: 469px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104910iC7BB8A83FFF73FB5/image-dimensions/469x101?v=v2" width="469" height="101" role="button" title="Werner_E_6-1716451180771.png" alt="Werner_E_6-1716451180771.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_7-1716451191923.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/104911i361B27B877DDBBE9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Werner_E_7-1716451191923.png" alt="Werner_E_7-1716451191923.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 08:11:26 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951693#M212013</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2024-05-23T08:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: BUG: inconsequent behaviour of match() function.</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951737#M212014</link>
      <description>&lt;P&gt;The function in the help example is an f(a, b) and it uses z....????&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 10:33:10 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951737#M212014</guid>
      <dc:creator>LucMeekes</dc:creator>
      <dc:date>2024-05-23T10:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: BUG: inconsequent behaviour of match() function.</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951776#M212016</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/14826"&gt;@LucMeekes&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The function in the help example is an f(a, b) and it uses z....????&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN class="HwtZe"&gt;&lt;SPAN class="jCAhz JxVs2d ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;The help in Prime could be improved to a large extent in many respects - especially when it comes to concrete usage examples directly where the functions are described. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="jCAhz JxVs2d ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;It's almost extraordinary for Prime standards that an example is given for this optional function - it's certainly not a very successful one. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="jCAhz JxVs2d ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;The z mentioned in the function is the value that is passed as the first parameter for "match".&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="jCAhz JxVs2d ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;So you would have to change the function every time you pass a different first parameter to "match" - pretty nonsensical.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;BR /&gt;&lt;SPAN class="jCAhz JxVs2d ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;As I wrote above, it makes much more sense to use the function parameter b instead of z.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="HwtZe"&gt;&lt;SPAN class="jCAhz JxVs2d ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;Its no surprise that the help is of no help to find out that the second argument of the boolean function corresponds to the first argument of "match" and the first argument of the boolean function corresponds to the values in the vector (second argument of "match".&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 12:29:19 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/BUG-inconsequent-behaviour-of-match-function/m-p/951776#M212016</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2024-05-23T12:29:19Z</dc:date>
    </item>
  </channel>
</rss>

