The problem with using N
to generate arbitrary precision numbers is that is it will generate more digits of accuracy than asked for:
N[Sqrt[3], 10] // InputForm
(* 1.73205080756887729352744634150587236694`10. *)
N[Sqrt[3], 28] // InputForm
(* 1.73205080756887729352744634150587236694`28. *)
Probably the square root algorithm converges quadratically, so it's quite likely that it will generate quite a few extra digits of accuracy just by the discrete nature of the iterations. Why not keep the extra precision? But beyond that, arbitrary-precsion numbers always carry at least a few extra guard bits, so that rounding error is unlikely to undermine the precision tracking.
The upshot is that given the near unpredictability of the number of digits in the internal representation of arbitrary-precision numbers, it's virtually impossible to subtract off the first few digits as the OP desires by using N
.
Instead one should use Round
or Floor
, depending on what is meant by "the exact 99 decimal places" and so forth.
Round[Sqrt[3], 1*^-99] - Round[Sqrt[3], 1*^-9]
% // N
(*
-(67362922886336509139707442665186679092128026866280159460635466107999\
99420607090831917991/
1562500000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000)
-4.31123*10^-10
*)
Floor[Sqrt[3], 1*^-99] - Floor[Sqrt[3], 1*^-9]
% // N
(*
2275509174109785366023489467771221015241522512223227917807732067635200\
1483245847470289943/\
4000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000
5.68877*10^-10
*)
Update: Answer to the "What's the point?" question
Much of this is explained in the tutorial Numerical Precision
and discussed further in my answer to Increasing the precision of a calculation. Basically a precision of $p$ in a number $x$ represents an (absolute) error or uncertainty of at most $10^{-p}x$; in other words, it represents a relative error of $10^{-p}$. When Mathematica displays a arbitrary-precision number of precision $p$, it displays only the digits which are certain, that is, $p$ of them (rounded).
When you add or subtract numbers the uncertainties are added and the precision changes. In the OP's example N[Sqrt[3],100]-N[Sqrt[3],10]
, we have two nearly equal numbers (two approximations to Sqrt[3]
) being subtracted. The uncertainty will be about $(10^{-10}+10^{-100})\sqrt{3} \approx \sqrt{3}\times 10^{-10}$. In the OP's example, the two terms of the difference agree past the first ten digits, so the result is smaller than the uncertainty. When that happens Mathematica gives 0
as the answer with an accuracy that reflects the uncertainty:
N[Sqrt[3], 100] - N[Sqrt[3], 10] // InputForm
(* 0``9.761439372640167 *)
10^-Accuracy[%]
(* 1.73205*10^-10 *)
Note that the Accuracy[]
reflects an uncertainty of around $\sqrt{3}\times 10^{-10}$ as claimed.
So the point, or at least a point, of arbitrary precision is to make tracking the propagation of error through a computation automatic, and to give users, not to mention built-in functions, the tools for doing so. (Just a little caveat: The calculation of precision is approximate, although quite accurate. There must be edge-cases where there are issues. I don't seem to recall any serious examples, though. One can use Interval[]
for rigorous bounds, but computations with Interval[]
sometimes give rather loose bounds.)