(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.0' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 8170, 272]*) (*NotebookOutlinePosition[ 8840, 295]*) (* CellTagsIndexPosition[ 8796, 291]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["About N (Version 4 only)", "Title", TextAlignment->Center, Background->RGBColor[0, 1, 1]], Cell["\<\ This notebook is by Steven Amgott. Please send any questions or\ \[NonBreakingSpace]comments to samgott1@swarthmore.edu. Feel free to use and \ distribute this notebook, but keep this author information in any copy you \ use or distribute.\ \>", "SmallText"], Cell[TextData[{ "In versions of ", StyleBox["Mathematica", FontSlant->"Italic"], " ", StyleBox["other than 4", FontColor->RGBColor[1, 0.501961, 0]], ", the function ", StyleBox["N[", FontColor->RGBColor[1, 0, 0]], StyleBox["expression", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], StyleBox[", ", FontColor->RGBColor[1, 0, 0]], StyleBox["number", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], StyleBox["]", FontColor->RGBColor[1, 0, 0]], " displays a numerical approximation to ", StyleBox["expression", FontSlant->"Italic"], " with ", StyleBox["number", FontSlant->"Italic"], " significant digits. However, in ", StyleBox["Mathematica", FontSlant->"Italic", FontColor->RGBColor[1, 0.501961, 0]], StyleBox[" 4", FontColor->RGBColor[1, 0.501961, 0]], ", this doesn't always happen. For instance," }], "Text"], Cell[BoxData[ \(N[\[Pi], 10]\)], "Input"], Cell[TextData[{ "only displays six significant digits on my office computer. (The actual \ number depends on the settings of machine variables in the copy of ", StyleBox["Mathematica", FontSlant->"Italic"], " you are using and on the computer you are using. The default after \ installation is usually six.) However," }], "Text"], Cell[BoxData[ \(N[\[Pi], 20]\)], "Input"], Cell["does produce the 20 digits. What is going on?", "Text"], Cell[TextData[{ "The answer is that in the past ", StyleBox["Mathematica", FontSlant->"Italic"], " used the argument ", StyleBox["number ", FontSlant->"Italic"], "to both choose the precision of the computation of expression and the \ number of digits to display. Now it uses it for the precision of the \ computation, but the number of displayed digits depends on whether the result \ is a \"machine-precision\" number or an \"arbitrary precision\" number. On \ my computer, when there are 16 or fewer digits, ", StyleBox["Mathematica", FontSlant->"Italic"], " treats the number as machine-precision. If there are 17 or more digits, \ the number is arbitrary precision, and ", StyleBox["N[", FontColor->RGBColor[1, 0, 0]], StyleBox["expression", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], StyleBox[", ", FontColor->RGBColor[1, 0, 0]], StyleBox["number", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], StyleBox["]", FontColor->RGBColor[1, 0, 0]], " returns all the digits." }], "Text"], Cell["\<\ To see what numbers on your machine are treated as machine-precision numbers, \ you can evaluate\ \>", "Text"], Cell[BoxData[ \($MachinePrecision\)], "Input"], Cell[TextData[{ "For more details, see the sections ", Cell[BoxData[ ButtonBox[\(3.1 .4\), ButtonData:>{"3.1.4", "4.11"}, ButtonStyle->"MainBookLink"]]], ", ", Cell[BoxData[ ButtonBox[\(3.1 .5\), ButtonData:>{"3.1.5", "4.11"}, Active->True, ButtonStyle->"MainBookLink"]]], ", and ", Cell[BoxData[ ButtonBox[\(3.1 .6\), ButtonData:>{"3.1.6", "6.2"}, ButtonStyle->"MainBookLink"]]], " in the ", StyleBox["Mathematica", FontSlant->"Italic"], " book. Clicking on one of those section numbers in this cell should open \ the relevant section in the Help Browser (provided the main book is installed \ on the computer you are using). Another source of information is the \ Technical Support pages at Wolfram Research. The article where I originally \ found some of this information is (as of 11/2/2001) located at:" }], "Text"], Cell[TextData[{ " ", ButtonBox["http://support.wolfram.com/mathematica/mathematics/numerics/\ nprintprecision.html", ButtonData:>{ URL[ "http://support.wolfram.com/mathematica/mathematics/numerics/\ nprintprecision.html"], None}, ButtonStyle->"Hyperlink"] }], "Text", TextAlignment->Center, TextJustification->0], Cell[TextData[{ "In that article, they suggest using ", StyleBox["NumberForm", FontColor->RGBColor[1, 0, 0]], " to control the display of your result. For instance, to get the first 10 \ digits of \[Pi], you could use" }], "Text"], Cell[BoxData[ \(NumberForm[N[\[Pi]], 10]\)], "Input"], Cell[TextData[{ "There are times when simply using ", StyleBox["NumberForm", FontColor->RGBColor[1, 0, 0]], " will not work. For instance," }], "Text"], Cell[BoxData[{ \(NumberForm[N[Sin[1.0]], 30]\), "\[IndentingNewLine]", \(Precision[%]\)}], "Input"], Cell[TextData[{ "(The ", StyleBox["Precision", FontColor->RGBColor[1, 0, 0]], " command gives the number of significant decimal digits. A similar \ command, ", StyleBox["Accuracy", FontColor->RGBColor[1, 0, 0]], ", gives the number of significant decimal digits to the right of the \ decimal point.) " }], "Text"], Cell["\<\ The reason it does not work is that the number 1.0 is a machine-precision \ number, and only has precision 16. \ \>", "Text"], Cell[BoxData[ \(Precision[1.0]\)], "Input"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " will only try to match the precision of the input. In the following \ cell, the input only has precision 20, so even though we ask for 30 digits we \ only get 20 in the output." }], "Text"], Cell[BoxData[{ \(Precision[1.00000000000000000000]\), "\n", \(N[Sin[1.00000000000000000000], 30]\), "\n", \(Precision[%]\)}], "Input"], Cell["If we have 30 digits in the input, then it works.", "Text"], Cell[BoxData[{ \(N[Sin[1.000000000000000000000000000000], 30]\), "\[IndentingNewLine]", \(Precision[%]\)}], "Input"], Cell["\<\ Typing in a large number of zeros is tiresome, so there is a way around it.\ \>", "Text"], Cell[BoxData[{ \(SetPrecision[N[Sin[1.0]], 30]\), "\[IndentingNewLine]", \(Precision[%]\)}], "Input"], Cell[TextData[{ "(There is also a similar ", StyleBox["SetAccuracy", FontColor->RGBColor[1, 0, 0]], " command.)" }], "Text"] }, Open ]] }, FrontEndVersion->"5.0 for Microsoft Windows", ScreenRectangle->{{0, 1280}, {0, 971}}, WindowToolbars->"EditBar", WindowSize->{583, 566}, WindowMargins->{{0, Automatic}, {Automatic, 0}} ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1776, 53, 99, 2, 111, "Title"], Cell[1878, 57, 270, 5, 44, "SmallText"], Cell[2151, 64, 914, 33, 71, "Text"], Cell[3068, 99, 45, 1, 30, "Input"], Cell[3116, 102, 342, 7, 71, "Text"], Cell[3461, 111, 45, 1, 30, "Input"], Cell[3509, 114, 62, 0, 33, "Text"], Cell[3574, 116, 1068, 29, 147, "Text"], Cell[4645, 147, 120, 3, 33, "Text"], Cell[4768, 152, 50, 1, 30, "Input"], Cell[4821, 155, 922, 25, 109, "Text"], Cell[5746, 182, 341, 11, 33, "Text"], Cell[6090, 195, 241, 6, 52, "Text"], Cell[6334, 203, 57, 1, 30, "Input"], Cell[6394, 206, 162, 5, 33, "Text"], Cell[6559, 213, 108, 2, 50, "Input"], Cell[6670, 217, 332, 10, 52, "Text"], Cell[7005, 229, 135, 3, 33, "Text"], Cell[7143, 234, 47, 1, 30, "Input"], Cell[7193, 237, 262, 6, 52, "Text"], Cell[7458, 245, 148, 3, 70, "Input"], Cell[7609, 250, 65, 0, 33, "Text"], Cell[7677, 252, 125, 2, 50, "Input"], Cell[7805, 256, 99, 2, 33, "Text"], Cell[7907, 260, 110, 2, 50, "Input"], Cell[8020, 264, 134, 5, 33, "Text"] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)