(***********************************************************************
Mathematica-Compatible Notebook
This notebook can be used on any computer system with Mathematica 3.0,
MathReader 3.0, or any compatible application. The data for the notebook
starts with the line of 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[ 26822, 862]*)
(*NotebookOutlinePosition[ 27854, 895]*)
(* CellTagsIndexPosition[ 27810, 891]*)
(*WindowFrame->Normal*)
Notebook[{
Cell[CellGroupData[{
Cell[TextData["13. Reprise: Syntax and Data Types"], "Title",
Evaluatable->False,
AspectRatioFixed->True],
Cell["Last revision: February 18 1998", "SmallText",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[
"In this lesson we take a break from our long march of new functions and \
consider some basic programming language topics: operator associativity and \
machine precision."], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox["Mathematica",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[" operations/structures introduced: \n",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox[" IntegerDigits[",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["number",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier",
FontSlant->"Italic"],
StyleBox[", ",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["base",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier",
FontSlant->"Italic"],
StyleBox[
"]\n $MinMachineNumber\n $MaxMachineNumber\n $MachinePrecision",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"]
}], "SmallText",
Evaluatable->False,
AspectRatioFixed->True],
Cell[CellGroupData[{
Cell[TextData["Operator Associativity "], "Section",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox["We learned at the beginning of the course that ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["Mathematica",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[
" interprets some operations as having precedence over others, such as \
multiplication over addition. In this way ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["Mathematica",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[
" can begin to parse an expression, which is to say to decide which parts \
of it to execute first. A moment's thought about how to order the operations \
in an expression, however, leads one to the conclusion that knowing \
precedence is not enough. What if, for example, there are several of the \
same operation in a row, as in \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["2 + 3 + 2",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" or \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["2 ^ 3 ^ 2",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\"? In the first case, we know that addition is associative, so that it \
does not matter whether ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["Mathematica",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[" chooses to evaluate \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["(2+3)+2",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" or \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["2+(3+2)",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\". However, for exponentiation, it surely makes a difference: \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["(2^3)^2",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" evaluates to 8^2=64, while \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["2^(3^2)",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" evaluates to 2^9=512. Every operator in ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["Mathematica",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[
", or any other language, must have its associativity specified, i.e., how \
a sequence of values, consecutively joined by such an operator, should be \
parenthesized. Operators are typically either left-associative or \
right-associative; left-associative operators group (or parenthesize) from \
the left (so that \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["2+2+2+2",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" becomes \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["((2+2)+2)+2",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\"), while right-associative operators group from the right (so that \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["2^3^2",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" becomes \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["2^(3^2)",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"). ",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox[
"Left-associative operators which we have considered are subtraction (\"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["-",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"), division (\"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["/",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"), the function-call operator (\"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["[.]",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"), and the part-extraction operator (\"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["[[.]]",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\"). Right-associative operators we have considered include \
exponentiation (\"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["^",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"), the boolean not operator (\"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["!",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"), and the assignment operator (\"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["=",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"). For many other operators in ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["Mathematica",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[
", the associativity is irrelevant because the operations are \
mathematically associative: one can parenthesize values connected by such \
operators in any way and end up with the same answer, such as addition (\"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["+",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"), multiplication (\"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["*",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"), the boolean and operator (\"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["&&",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"), and the boolean or operator (\"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["||",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"). ",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox[
"At first glance, one might wonder why all operators are not \
left-associative. For an example of why an operator should be \
right-associative, we consider the most important right-associative operator, \
namely, the assignment operator \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["=",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\". The assignment operator is right-associative so that one can assign \
one value to several variables, as in the statement \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["a = b = 3",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\". It works as follows: since \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["=",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" is right-associative, the expression is grouped as \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["a=(b=3)",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\", the subexpression \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["b=3",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" is evaluated (which sets \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["b",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" to \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["3",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" and returns the value 3), and then the expression \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["a=3",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" is evaluated, setting \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["a",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" to the value \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["3",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\". If it were left-associative, the evaluation would be otherwise: the \
grouping would be \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["(a=b)=3",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\", so \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["a=b",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" would be evaluated (and \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["a",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" would be assigned the value \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["b",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\"), and then, since \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["b",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" was the return value of \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["(a=b)",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\", the expression \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["b=3",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" would be evaluated. At the end, then, \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["b",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" would have the value \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["3",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" and \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["a",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" would have the old value of \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["b",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\", which is not a behavior we would like.",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True]
}, Closed]],
Cell[CellGroupData[{
Cell[TextData["Machine-Precision Numbers"], "Section",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"Recall that ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" separates numbers into two categories: exact (Integers, Rationals, and \
any other data type using which it is possible to represent a number exactly) \
on one hand, and numerical approximations on the other, in which the \
precision is limited and implicitly specified (such as a Real number which, \
for all ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" knows, is only an approximation up to the number of digits you specified: \
1.0 approximates some number which is less than 0.5 away from 1.0). Numbers \
can also be separated according to whether or not they are machine-precision. \
On most computers, there are special internal data types called \
machine-precision integers and machine-precision approximations, and we cover \
these data types because in most programming languages, the numbers that a \
programmer works with must be machine-precision. There is a significant \
advantage to using machine-precision numbers: computers can manipulate and \
compute with these numbers much more quickly than with those which are not \
machine-precision. ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" does a yeoman's job of masking this distinction, making us believe that \
all numbers, regardless of size, are easily to manipulate, but this is not \
really true!"
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[CellGroupData[{
Cell[TextData["Machine-Precision Integers"], "Subsection",
Evaluatable->False,
AspectRatioFixed->True],
Cell["\<\
Each computer, be it a PowerMac, an IBM-compatible personal \
computer, a Hewlett-Packard workstation, or a Cray supercomputer, has a \
certain size of integers that it can store and manipulate easily. Since \
computers represent integers using bits, which are binary digits taking only \
the values zero and one, we consider the size of an integer to be the number \
of bits required to represent it in base 2.\
\>", "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox[
"What is \"base 2\"? Our number system is base 10, by which we mean that \
when we write down a number, the place values (from right to left) are 1s, \
10s, 100s, 1000s, and so on. Thus the number 345 means (thinking \
right-to-left) ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["5+4*10+3*100",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[" or (thinking left-to-right) ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["3*100+4*10+5",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
". In base 2, the place values are similarly powers, but are, instead of \
powers of 10, powers of 2: 1s, 2s, 4s, 8s, 16s, and so on. Thus the number \
1001 in base 2 means (thinking right-to-left) ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["1+0*2+0*4+1*8",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[" or (thinking left-to-right) ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["1*8+0*4+0*2+1",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
". Notice that in base 10 we have the digits 0 through 9; in base 2, the \
only digits allowed are 0 and 1. From mathematics class we know that any \
integer can be written in base 10 or base 2, and, in fact, ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["Mathematica",
Evaluatable->False,
AspectRatioFixed->True,
FontSlant->"Italic"],
StyleBox[
" has a command that turns a normal number (written in base 10) into its \
base 2 form: \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["IntegerDigits[ ... ,2]",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\". For instance, \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["IntegerDigits[10,2]",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\" gives the base 2 representation of the number of fingers on our hands.",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell["IntegerDigits[10,2]", "Input",
AspectRatioFixed->True],
Cell[TextData[{
StyleBox["Note that four bits were necessary, since ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["10=1*2^3+0*2^2+1*2+0",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
". How large a number could a computer represent if it allowed 4 bits? \
Well, the maximum number would be derived by choosing every digit to be the \
largest possible, which in this case is to make every digit a 1. We find \
then that the largest 4-bit base 2 number is ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["1*2^3+1*2^2+1*2+1",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
" (taking all of the bits to be 1), which is 15. There is a formula to \
compute the largest integer expressible by using \"n\" bits: \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["(2^n)-1",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\". If a computer allows \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["n",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\"-bit integers, and we use all of the bits for the base 2 representation \
of an integer, then we could represent the integers from 0 to \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["(2^n)-1",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\".",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox[
"However, most computer users have a use for negative numbers also. In \
order to signal whether or not an integer is positive or negative, we can \
devote to an indication of the sign: if the designated bit is zero, the \
integer is positive, while if the designated bit is one, then the integer is \
negative. Hence, if we had 4 bits and used one for the sign bit, then the \
largest positive integer would be ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["2^3-1",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
", or 7. What would the largest negative number be? We could form the \
largest positive number and then use the sign bit to indicate that it is \
negative, yielding \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["-(2^(n-1)-1)",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\", where \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["n",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\" is the number of total bits, counting the sign bit. Putting these two \
facts together, if a computer represents integers with \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["n",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\" bits, counting the sign bit, then the range of integers expressible is \
",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["-(2^(n-1)-1)",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[" to ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["(2^(n-1))-1",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[". ",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox["(The attentive reader will notice that we have ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["2^n",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[" possible values with \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["n",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox["\" bits, and if we have ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["2^(n-1)-1",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[" positive numbers, ",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["2^(n-1)-1",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
" negative numbers, and a value representing zero, we still have one \
pattern of bits left over, namely all zeros with the sign bit turned on. \
Different computer processors evaluate this number differently, and for our \
purposes we ignore this discrepancy.)",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True]
}, Closed]],
Cell[CellGroupData[{
Cell[TextData["Machine-Precision Approximations"], "Subsection",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox[
"The range of integers that a computer can easily store exactly is quite \
limited, as the preceding section should have convinced you. However, \
computers are widely used to handle much larger numbers--albeit with an \
accuracy trade-off. Recall from high school how numbers are represented in \
scientific notation: \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["x.xxxxx * 10^y",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\". Instead of restricting the range of values of an integer, computers \
can restrict the number of digits of precision of a numeric approximation \
such as \"",
Evaluatable->False,
AspectRatioFixed->True],
StyleBox["x.xxxx * 10^y",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Courier"],
StyleBox[
"\", as well as a power of ten with which to multiply the number. \
Computers usually allow a fixed number of digits (actually, a fixed number of \
bits) for the mantissa (the part with x's) and a fixed number of digits \
(actually, a fixed number of bits) for the exponent (the y). The number 2.5, \
for instance, has mantissa 2.5 and exponent 0; the number 0.00001234 has \
mantissa 1.234 and exponent -5. Similarly, the number 123400000 has mantissa \
1.234 and exponent 6. As you might imagine, if the number in question has \
more significant digits than a mantissa will allow, then the computer can \
only store an approximation. For instance, suppose the mantissa is allowed \
to be no greater than 5 decimal digits. Then the computer in question could \
not distinguish between 1234567890000 and 1234567899999, since each would be \
stored as 1.2345 * 10^12. ",
Evaluatable->False,
AspectRatioFixed->True]
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"We can ask ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" the largest positive and smallest positive numbers that the computers we \
are using can handle:"
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell["$MinMachineNumber", "Input",
AspectRatioFixed->True],
Cell[TextData["gives the smallest positive number, while"], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell["$MaxMachineNumber", "Input",
AspectRatioFixed->True],
Cell[TextData["gives the largest positive number."], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"To ask how many decimal digits the machine keeps in a machine-precision \
approximation, we ask ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" to evaluate the following:"
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],
Cell["$MachinePrecision", "Input",
AspectRatioFixed->True]
}, Closed]]
}, Closed]]
}, Open ]]
},
FrontEndVersion->"Macintosh 3.0",
ScreenRectangle->{{0, 832}, {0, 604}},
WindowToolbars->{},
WindowSize->{520, 509},
WindowMargins->{{Automatic, 116}, {15, Automatic}},
PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}},
ShowCellLabel->True,
ShowCellTags->False,
RenderingOptions->{"ObjectDithering"->True,
"RasterDithering"->False},
MacintoshSystemPageSetup->"\<\
00<0004/0B`000002n88o?mooh<"
]
(***********************************************************************
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[1731, 51, 110, 2, 136, "Title",
Evaluatable->False],
Cell[1844, 55, 101, 2, 26, "SmallText",
Evaluatable->False],
Cell[1948, 59, 245, 5, 46, "Text",
Evaluatable->False],
Cell[2196, 66, 925, 34, 82, "SmallText",
Evaluatable->False],
Cell[CellGroupData[{
Cell[3146, 104, 103, 2, 50, "Section",
Evaluatable->False],
Cell[3252, 108, 3749, 120, 251, "Text",
Evaluatable->False],
Cell[7004, 230, 2793, 96, 150, "Text",
Evaluatable->False],
Cell[9800, 328, 4644, 161, 199, "Text",
Evaluatable->False]
}, Closed]],
Cell[CellGroupData[{
Cell[14481, 494, 102, 2, 30, "Section",
Evaluatable->False],
Cell[14586, 498, 1450, 28, 244, "Text",
Evaluatable->False],
Cell[CellGroupData[{
Cell[16061, 530, 106, 2, 46, "Subsection",
Evaluatable->False],
Cell[16170, 534, 484, 9, 94, "Text",
Evaluatable->False],
Cell[16657, 545, 2289, 69, 213, "Text",
Evaluatable->False],
Cell[18949, 616, 62, 1, 27, "Input"],
Cell[19014, 619, 1641, 49, 146, "Text",
Evaluatable->False],
Cell[20658, 670, 1986, 61, 162, "Text",
Evaluatable->False],
Cell[22647, 733, 1194, 38, 96, "Text",
Evaluatable->False]
}, Closed]],
Cell[CellGroupData[{
Cell[23878, 776, 112, 2, 30, "Subsection",
Evaluatable->False],
Cell[23993, 780, 1858, 40, 256, "Text",
Evaluatable->False],
Cell[25854, 822, 246, 8, 48, "Text",
Evaluatable->False],
Cell[26103, 832, 60, 1, 27, "Input"],
Cell[26166, 835, 115, 2, 30, "Text",
Evaluatable->False],
Cell[26284, 839, 60, 1, 27, "Input"],
Cell[26347, 842, 108, 2, 30, "Text",
Evaluatable->False],
Cell[26458, 846, 261, 8, 48, "Text",
Evaluatable->False],
Cell[26722, 856, 60, 1, 27, "Input"]
}, Closed]]
}, Closed]]
}, Open ]]
}
]
*)
(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)