úÎ3^0˜      non-portable experimentalEdward Kmett <ekmett@gmail.com>NoneHThis provides a numeric data type with effectively doubled precision by  using Knuth':s error free transform and a number of custom compensated  arithmetic circuits. AThis construction can be iterated, doubling precision each time. Rround (Prelude.product [2..100] :: Compensated (Compensated (Compensated Double)))ž93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000Prelude.product [2..100]ž93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000This extracts both the  and  components of a   number. Used internally to construct , values that satisfy our residual contract. When in doubt, use  a b  instead of  a b This  number is used to  - the significand in half, so we can multiply - them separately without losing precision in .  a b k computes k x y such that   x + y = a + b  x = fl(a + b) Which is to say that x is the floating point image of (a + b) and  y! stores the residual error term.  a b k computes k x y such that   x + y = a + b  x = fl(a + b) #but only under the assumption that  a   b . If you  aren' t sure, use . Which is to say that x is the floating point image of (a + b) and  y! stores the residual error term.  a b k computes k x y such that   x + y = a * b  x = fl(a * b) Which is to say that x is the floating point image of (a * b) and  y! stores the residual error term. GThis could be nicer if we had access to a hardware fused multiply-add. Priest's renormalization algorithm  renorm a b c generates a  number assuming a  b  c.   a k computes k x y such that   x + y = a * a  x = fl(a * a) Which is to say that x is the floating point image of (a * a) and  y! stores the residual error term. 1Calculate a fast square of a compensated number. <error-free split of a floating point number into two parts. %Note: these parts do not satisfy the  contract ;Calculate a scalar + compensated sum with Kahan summation. Compute a *  a ^This provides the isomorphism between the compact representation we store these in internally  and the naive pair of the  and  components. This  lets us edit the  directly, leaving the  untouched. This  lets us edit the  directly, leaving the  untouched.  Extract the  component of a ! value, when and if compensation  is no longer required. %Perform Kahan summation over a list. TODO: do this right! NB:) Experimental and partially implemented. •Other than sqrt, the accuracy of these is basically uncalculated! In fact many of these are known to be wrong! Patches and improvements are welcome. 3   !"#$%&'()*+,-./012345    /   !"#$%&'()*+,-./0123456      !"#$%&'()*+,-./0123456789:;<=>compensated-0.2Numeric.CompensatedOvercompensated Compensable Compensatedwith compensatedmagicaddfaddtimesdividesquaredsquaresplit+^*^ _Compensatedprimalresidual uncompensatedkahanbaseGHC.Numabsghc-prim GHC.Classes>=renorm lens-3.8.7.3Control.Lens.TypeLens$fPreciseCompensated$fFloatingCompensatedcompensatedConstrcompensatedDataType$fVectorVectorCompensated$fMVectorMVectorCompensated$fStorableCompensated$fSafeCopyCompensated$fSerializeCompensated$fBinaryCompensated$fRealFracCompensated$fRealCompensated$fFractionalCompensated$fEnumCompensated$fNumCompensated $fSnocpfCompensatedCompensatedab $fConspfCompensatedCompensatedab$fMonoidCompensated$fSemigroupCompensated$fOrdCompensated$fEqCompensated$fEachfCompensatedCompensatedab$fReadCompensated$fShowCompensated$fDataCompensated$fHashableCompensated$fTypeable1Compensated$fCompensableCompensated$fCompensableFloat$fCompensableDouble