About relational tests tolerance
Jan 05, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Jan 05, 2010
03:00 AM
About relational tests tolerance
Hi guys. Sorry if the question was answered long time ago, but I had not find it in older posts. It is about tolerance in relational tests in MC 2001. I guess this is known for all you but I'm relatively new to MC and it keeps surprising me.
One of my functions is giving wrong results in some rare cases. This function finds the minimum value of an array, locate that minimum, do some calcs and test the result against a reference value. After manually tracing the error I finally learned that:
- "min" function returns the true minimum value.
- "match" function returns position of match according to value of TOL.
- relational tests (<,=,>) work with a fixed tolerance of about 10^-13.
When 2 computed values differ in the least significant digits, maybe due to rounding, the described method can fail 'cause is not picking the true minimum value.
As work-around I found that I can lower the default tolerance to 10^-16 to make "match" return the true position of the true minimum, and doing relational tests against zero, i.e. test "a-b < 0" instead of "a < b".
My question: can I trust that the test against zero will work always? Testing against zero will do an absolute test?
Saludos,
Al
One of my functions is giving wrong results in some rare cases. This function finds the minimum value of an array, locate that minimum, do some calcs and test the result against a reference value. After manually tracing the error I finally learned that:
- "min" function returns the true minimum value.
- "match" function returns position of match according to value of TOL.
- relational tests (<,=,>) work with a fixed tolerance of about 10^-13.
When 2 computed values differ in the least significant digits, maybe due to rounding, the described method can fail 'cause is not picking the true minimum value.
As work-around I found that I can lower the default tolerance to 10^-16 to make "match" return the true position of the true minimum, and doing relational tests against zero, i.e. test "a-b < 0" instead of "a < b".
My question: can I trust that the test against zero will work always? Testing against zero will do an absolute test?
Saludos,
Al
Labels:
- Labels:
-
Other
3 REPLIES 3
Jan 06, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Jan 06, 2010
03:00 AM
If you go to tools, worksheet options, calculation, do you have a check box "Use exact equality for boolean comparisons"?
Richard
Richard
Jan 06, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Jan 06, 2010
03:00 AM
On 1/6/2010 2:39:40 PM, rijackson wrote:
>If you go to tools, worksheet
>options, calculation, do you
>have a check box "Use exact
>equality for boolean
>comparisons"?
Nope, MC2001 do not have that option.
Al
>If you go to tools, worksheet
>options, calculation, do you
>have a check box "Use exact
>equality for boolean
>comparisons"?
Nope, MC2001 do not have that option.
Al
Jan 06, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Jan 06, 2010
03:00 AM
Yes, you are right. It was introduced in version 11. Here's the Quicksheet.
Richard
Richard
