I have several questions regarding the function $$f(x)=\frac{\sqrt{x^2+9}-3}{x^2}$$ that I would like to help my students with in the upcoming semester.
Now, the limit as $x\to 0$ is 1/6.
Limit[f[x], x -> 0]
(* 1/6 *)
My first question regards approximating the limit as $x\to 0$ using a table.
Clear[f]
f[x_] := (Sqrt[x^2 + 9] - 3)/x^2; data =
Table[{N[10^(-n)], N[f[10^(-n)]]}, {n, 0, 8}];
Grid[Prepend[data, {"x", "f(x)"}],
Alignment -> Left,
Frame -> All]
Which gives the following table.
The point of this example is to show students that technology will sometimes get into a little trouble and might show information that leads students to assume an incorrect answer.
If I recall, the problem here is the fact that if you subtract two numbers that are really close to one another, you can quickly lose enough precision so that the numerator is interpreted as zero.
g[x_] := Sqrt[x^2 + 9] - 3;
Grid[Table[{N[10^(-n)], N[g[10^(-n)]]}, {n, 0, 8}],
Alignment -> Left,
Frame -> All]
Now, on a calculator, you are usually stuck as you cannot increase the precision. I think you can in Mathematica, but I've never tried it as yet. So, my first question is, how do I increase the Mathematica precision in these examples and increase the number of decimal places shown to demonstrate to the students what is going on here?
My second equation regards the graph of this equation. As you zoom in near zero, you begin to see some vibrations, maybe indicating that the limit does not exist.
Plot[f[t], {t, -10^(-6), 10^(-6)},
PlotRange -> {{-10^(-6), 10^(-6)}, {-0.1, 0.3}},
AxesLabel -> {"t", "y"}]
Again, can this particular image be improved by increasing the machine precision? How can I best explain this situation to the students?
Update: Consider the following image:
Clear[f]
f[x_] := (Sqrt[x^2 + 9] - 3)/x^2;
Plot[f[t], {t, -10^(-7), 10^(-7)},
PlotRange -> {{-10^(-7), 10^(-7)}, {-0.1, 0.3}},
AxesLabel -> {"t", "y"}]
What would be a good way to figure out exactly what points are being plotted here and why?
With[{prec = 30}, Table[{N[10^(-n), prec], N[g[10^(-n)], prec]}, {n, 0, 8}]]
. But you already knew about the second argument ofN[]
, no? As for your plotting question, look upWorkingPrecision
. $\endgroup$WorkingPrecision
option $\endgroup$3 + x^2/6 - x^4/216
. With evaluate around 10^(-8) and we expect, after subtraction of the second term (3), to have a residual slightly larger than 10^(-17), which means we have lost all significant digits if we are working with standard machine doubles (where an ULP is around 10^(-16)). $\endgroup$