MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

A repair to Real Number comparison so Fateman's examples do not exhibit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106953] A repair to Real Number comparison so Fateman's examples do not exhibit
  • From: Richard Fateman <fateman at cs.berkeley.edu>
  • Date: Fri, 29 Jan 2010 07:47:35 -0500 (EST)

---------------------------------
(* Here's a fix for Mathematica that makes MY examples work better.
The challenge to you, should you care to accept it, is to find a 
mathematical program that you have been running previously
successfully, that FAILS with this fix.
*)


Unprotect[Greater,Less]

Greater[x_,y_/;inSameFuzzBallNE[x,y]]:=True
Less[x_,y_]:= Greater[y,x]

(* two numbers that are close but not equal*)

inSameFuzzBallNE[x_,y_]:=(Head[x]===Real || Head[y]===Real)&&(x!=y)&&
    Interval[]=!=IntervalIntersection[Interval[x],Interval[y]]

(* that's all.

But here's an optional hack to display all
low-precision numbers in RED *)

$LowPrecisionWarningLimit=1
PrintShowFuzz[x_] :=
  x /. (r_Real /; (Precision[r] < $LowPrecisionWarningLimit) -> 
Style[InputForm[r], Red])
$PrePrint=PrintShowFuzz
	
(*examples*)
x=0``-.5
{x==0,x==1,x<=1,x<1,x}


  • Prev by Date: Re: Ha! a document that FAILS because it is in notebook
  • Next by Date: Using variable name as string AND value ?
  • Previous by thread: Re: Prime Segment Diagram; why the codes run very slowly?
  • Next by thread: Using variable name as string AND value ?