Comparison tolerance: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(Created page with "'''Tolerant comparison''' is an inexact form of comparison used to mitigate the impact of floating-point rounding error on programs. It considers two numbers equal when their relative difference is smaller than a parameter called the '''comparison tolerance''', and accessed with the system variable <syntaxhighlight lang=apl inline>⎕CT</syntaxhighlight>. In addition to the comparison functions, tolerance applies to Match and Not Match, Floor, C...")
 
No edit summary
Line 1: Line 1:
'''Tolerant comparison''' is an inexact form of [[comparison]] used to mitigate the impact of floating-point rounding error on programs. It considers two [[number]]s equal when their relative difference is smaller than a parameter called the '''comparison tolerance''', and accessed with the [[system variable]] <syntaxhighlight lang=apl inline>⎕CT</syntaxhighlight>. In addition to the comparison functions, tolerance applies to [[Match]] and [[Not Match]], [[Floor]], [[Ceiling]], and [[Modulus]], and [[search functions]] defined in terms of Match (not [[Interval Index]]).
'''Tolerant comparison''' is an inexact form of [[comparison]] used to mitigate the impact of floating-point rounding error on programs. It considers two [[number]]s equal when their relative difference is smaller than a parameter called the '''comparison tolerance''', and accessed with the [[system variable]] <syntaxhighlight lang=apl inline>⎕CT</syntaxhighlight>. In addition to the comparison functions, tolerance applies to [[Match]] and [[Not Match]], [[Floor]], [[Ceiling]], and [[Modulus]], and [[search function]]s defined in terms of Match (not [[Interval Index]]).


{{quote|In an early talk Ken was explaining the advantages of tolerant comparison. A member of the audience asked incredulously, "Surely you don't mean that when <nowiki>A=B and B=C</nowiki>, A may not equal C?" Without skipping a beat, Ken replied, "Any carpenter knows that!" and went on to the next question.|—Paul Berry<ref>[[Roger Hui]]. [https://keiapl.org/anec/ Ken Iverson Quotations and Anecdotes]. 2005-09-30.</ref>}}
{{quote|In an early talk Ken was explaining the advantages of tolerant comparison. A member of the audience asked incredulously, "Surely you don't mean that when <nowiki>A=B and B=C</nowiki>, A may not equal C?" Without skipping a beat, Ken replied, "Any carpenter knows that!" and went on to the next question.|—Paul Berry<ref>[[Roger Hui]]. [https://keiapl.org/anec/ Ken Iverson Quotations and Anecdotes]. 2005-09-30.</ref>}}
Line 12: Line 12:
== References ==
== References ==
<references/>
<references/>
{{APL built-ins}}[[Category:Function characteristics]][[Category:System constants]]

Revision as of 03:38, 25 February 2024

Tolerant comparison is an inexact form of comparison used to mitigate the impact of floating-point rounding error on programs. It considers two numbers equal when their relative difference is smaller than a parameter called the comparison tolerance, and accessed with the system variable ⎕CT. In addition to the comparison functions, tolerance applies to Match and Not Match, Floor, Ceiling, and Modulus, and search functions defined in terms of Match (not Interval Index).

In an early talk Ken was explaining the advantages of tolerant comparison. A member of the audience asked incredulously, "Surely you don't mean that when A=B and B=C, A may not equal C?" Without skipping a beat, Ken replied, "Any carpenter knows that!" and went on to the next question.

—Paul Berry[1]

The formula now used for comparison tolerance was introduced in SHARP APL by Robert Bernecky and others,[2] following a proposal by Dick Lathwell.[3]

The application of comparison tolerance to search functions presents problems for standard hash-based search methods.[4][5]

External links

References

APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)
Quad names Index originComparison toleranceMigration levelAtomic vector