• Graph the Bessel function

    J0(x) = 1 - (x/2)2 + (x/2)4/2!2! - (x/2)6/3!3! + ...

    for 0 ≤ x < 50.

Here the problem is that if you just use the series for the whole range you get

What happens is that for large x the first several terms of the series grow very large. If x=40, for example, then the largest term is 1.85759 31153 4e+15, while the value of J0(40) is less than 1. So a lot of cancellation takes place in the computation. A computer stores real numbers as floating point numbers with a fixed precision - a sign s, and exponent e, and a number between 1 and 2 called the mantissa, which is allotted only about 52 bits. That number of bits is about 15 decimals. So the cancellations that take place in calculating J0(40) mean that the exact value of the sum is essentially meaningless.

This problem occurs whenever a computer takes the difference of two numbers approximately equal in size, and is sometimes called cancellation error. It occurs already in using the series for e-x with x large, but I chose the Bessel function because presumably you wouldn't know any other way to calculate it.

The way to draw the graph for large x is to use an approximation J0(x) = √(2/ π x) which I hoped you would figure out at least approximately by trial and error. This is the first term in an infinite asymptotic series for J0(x).

As for the TEX, I hoped you would use a loop to place the x-values more or less automatically.