Here are some hints, suggestions, and comments on the assignment.
Summing up vs. summing down
If you only consider relatively small N, you will not see any
difference between summing up and summing down, since both will have an
error about equal to the machine precision. So be sure to increase N
until you see a different trend (I used up to 10^8).
If you are looking for the effects of errors over a logarithmic
range (e.g., N from 10^2 to 10^8), you should vary N by multiplying
by a factor each time through a loop and not by adding 1 (or some other
number). That is, don't use:
for (N = 100; N <= 100000000; N++)
which will take an enormous amount of time calculating lots of N values
you don't need. Instead, use something like:
for (N = 100; N <= 100000000; N *= 10)
which just calculates for 100, 1000, 100000, etc.
When you output relative errors to a file for plotting,
the "scientific" format is usually most useful,
again because you are looking at logaithmic intervals.
(See the codes we've used in class for examples.)
It is only the absolute value of the relative error that is of
interest. So use "fabs" (you need to "input ").
It is particularly important to have only
positive numbers if you are going to plot on logarithmic scales!
Be careful that you don't confuse the machine precision with the
smallest floating point number. For example,
in single precision, the machine
precision is about 10-7, but that does not
mean that 10^-10 is set to zero. It is only when you add
two numbers that differ by a factor of more than
10-7 that the smaller number is effectively zero.
Mathematica Scavenger Hunt
When searching in the Help Browser (found under the Help menu),
it is often best to select "Master Index" first. Then guess a
general word related to the topic you are interested in. For
example, to find functions relating to prime numbers, type in
When you get some search results, be sure to scroll down and look
at all of the possibilities. For example, after searching for
"prime", the entry for "Primes" (which is well down the list) might
be the most useful.
Always check the function you use with a "?" in front. This will
make sure you have loaded the appropriate package (if necessary).
If you try using a function BEFORE loading the corresponding package,
you will find it doesn't work after loading, because you have created
an unintentional definition that takes precedence. You can use
Remove to eliminate the definition. E.g., AtomicWeight[Tungsten] <<Miscellaneous`ChemicalElements` ?AtomicWeight
Global`AtomicWeight Remove[AtomicWeight] ?AtomicWeight
AtomicWeight[element] gives the atomic weight of the
Remember that capitalization is critical: Atomicweight is NOT
the same as AtomicWeight.