Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: DigitDifferences?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60733] Re: DigitDifferences?
  • From: "Carl K. Woll" <carlw at u.washington.edu>
  • Date: Mon, 26 Sep 2005 01:36:10 -0400 (EDT)
  • Organization: University of Washington
  • References: <dh2tfe$d69$1@smc.vnet.net> <dh5hdu$dib$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Carl K. Woll wrote:
> Paul Abbott wrote:
>>I would like some suggestions on good implementations of the following
>> idea: suppose that you have two numbers whose floating point
>> representation has many common digits, say
>>
>>  2`50 Sum[(-1)^(k - 1)/(2 k - 1), {k, 1, 50000}]
>>
>>  1.5707863267948976192313211916397520520985833146875579625874449850433
>>
>> and
>>
>>  N[Pi/2, 50]
>>
>>  1.5707963267948966192313216916397514420985846996875529104874722962622
>>
>> Although these two numbers disagree in the 5th decimal place, they still
>> have a great many common digits from that point onwards.
>>
>> (By the way, if you are using OS X you can use the "Evaluate to Text"
>> MathService under the Services menu to do inline Mathematica evaluations
>> in your favourite newsreader, avoiding much of the cutting and pasting
>> to and from Mathematica. I used that here for the numerical evaluations.)
>>
>> I would like to display the differences between these numbers a la
>> Borwein Borwein and Dilcher (1989) in "Pi, Euler numbers and asymptotic
>> expansions", Amer. Math. Monthly 96 (1989), 681-687. To get an idea,
>> paste either cell below into a Notebook. These attempts were done by
>> hand -- so automated code for their production would be nice -- and they
>> have one unfortunate problem: the spacing between numbers is not
>> uniform. Suggestions for a DigitDifferences function most welcome.
>>
>> Cheers,
>> Paul
>>
>
> Another idea is to change the line spacing and create "invisible"
> characters. The Cell below carries out this idea. If you change the
> background color to something other than white or black you can see the
> invisible characters.
>

I overlooked the simpler idea of using underlining. Simply create three 
copies of your number, the above number with invisible 0s to get the spacing 
right, and with the visible numbers underlined, the base number with numbers 
underlined where the below numbers go, and the below number with invisibe 0s 
again. Then, adjust the spacing to tighten up things. I used 
LineSpacing->{1,-3}. This approach keeps the spacing between numbers 
uniform. The following text example shows the result:

Cell[TextData[{
StyleBox["0.00000000000000",
LineSpacing->{1, -3},
FontColor->GrayLevel[1]],
StyleBox["1",
LineSpacing->{1, -3},
FontVariations->{"Underline"->True}],
StyleBox["00000000000000000",
LineSpacing->{1, -3},
FontColor->GrayLevel[1]],
StyleBox["061\n",
LineSpacing->{1, -3},
FontVariations->{"Underline"->True}],
StyleBox["1.5707",
LineSpacing->{1, -3}],
StyleBox["8",
LineSpacing->{1, -3},
FontVariations->{"Underline"->True}],
StyleBox["6326794897619231321",
LineSpacing->{1, -3}],
StyleBox["1",
LineSpacing->{1, -3},
FontVariations->{"Underline"->True}],
StyleBox["9163975205209858",
LineSpacing->{1, -3}],
StyleBox["3314",
LineSpacing->{1, -3},
FontVariations->{"Underline"->True}],
StyleBox["6876\n",
LineSpacing->{1, -3}],
StyleBox["0.0000",
LineSpacing->{1, -3},
FontColor->GrayLevel[1]],
StyleBox["1",
LineSpacing->{1, -3}],
StyleBox["0000000000000000000",
LineSpacing->{1, -3},
FontColor->GrayLevel[1]],
StyleBox["5",
LineSpacing->{1, -3}],
StyleBox["0000000000000000",
LineSpacing->{1, -3},
FontColor->GrayLevel[1]],
StyleBox["1385",
LineSpacing->{1, -3}]
}], "Text"]

> Carl Woll
> Wolfram Research
>
> Cell[TextData[{
> "\n",
> StyleBox["0.00000000000000",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox["1",
> LineSpacing->{0, 0}],
> StyleBox["00000000000000000",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox["061",
> LineSpacing->{0, 0}],
> StyleBox["00000000000000",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox["\n",
> LineSpacing->{0, 0}],
> StyleBox["0.00000000000000",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox["_",
> LineSpacing->{0, 0}],
> StyleBox["00000000000000000",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox["___\n",
> LineSpacing->{0, 0}],
> StyleBox["\n",
> LineSpacing->{1, 0}],
> StyleBox["1.5707863267948976192313211916397520520985833146876\n",
> LineSpacing->{0, 0}],
> StyleBox["_",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox[".",
> LineSpacing->{0, 0}],
> StyleBox["____",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox["_",
> LineSpacing->{0, 0}],
> StyleBox["___________________",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox["_",
> LineSpacing->{0, 0}],
> StyleBox["________________",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox["____\n",
> LineSpacing->{0, 0}],
> StyleBox["\n",
> LineSpacing->{1, 0}],
> StyleBox["0.0000",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox["1",
> LineSpacing->{0, 0}],
> StyleBox["0000000000000000000",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox["5",
> LineSpacing->{0, 0}],
> StyleBox["0000000000000000",
> LineSpacing->{0, 0},
> FontColor->GrayLevel[1]],
> StyleBox["1385",
> LineSpacing->{0, 0}],
> "\n"
> }], "Text",
> FontColor->GrayLevel[0]]
>
>> Here my two attempts to display the sort of formatting required -- there
>> may be other better solutions:
>>
>>  Cell[BoxData[
>>    FormBox[
>>      RowBox[{"1.5707",
>>        UnderscriptBox["8",
>>          UnderscriptBox["_", "1"]], "632679489",
>>        UnderscriptBox[
>>          UnderscriptBox["7", "_"],
>>          RowBox[{"-", "1"}]], "619231321",
>>        UnderscriptBox["1",
>>          UnderscriptBox["_", "5"]], "9163975",
>>        UnderscriptBox[
>>          UnderscriptBox["205", "_"],
>>          RowBox[{"-", "61"}]], "209858",
>>        UnderscriptBox["3314",
>>          UnderscriptBox["_", "1385"]], "6876"}],
>>      TraditionalForm]], "Text"]
>>
>>
>>
>>   Cell[BoxData[
>>    FormBox[
>>      RowBox[{"1.5707", " ",
>>        UnderscriptBox["8",
>>          UnderscriptBox["_", "1"]], " ", "632679489", " ",
>>        OverscriptBox[
>>          OverscriptBox["7", "_"], "1"], " ", "619231321", " ",
>>        UnderscriptBox["1",
>>          UnderscriptBox["_", "5"]], " ", "9163975", " ",
>>        OverscriptBox[
>>          OverscriptBox["205", "_"], "61"], " ", "209858", " ",
>>        UnderscriptBox["3314",
>>          UnderscriptBox["_", "1385"]], " ", "6876"}],
>>      TraditionalForm]], "Text"]
>>
>> _______________________________________________________________________
>> Paul Abbott                                      Phone:  61 8 6488 2734
>> School of Physics, M013                            Fax: +61 8 6488 1014
>> The University of Western Australia         (CRICOS Provider No 00126G)
>> AUSTRALIA                               http://physics.uwa.edu.au/~paul
>>
>
>

Carl Woll
Wolfram Research 


  • Prev by Date: Re: Is this possible? Residue computation leads to complexInfinity?
  • Next by Date: Re: After upgrade of X Server, Mathematica won't work properly
  • Previous by thread: Re: DigitDifferences?
  • Next by thread: Re: DigitDifferences?