# SetPrecision within Block

I am reading Mathematica Cookbook, chapter 1.

Author gives two examples, with the following explanation

You can control precision within a complex calculation (without using N[] on every intermediate result) by changing these values; however, you should only do so within a Block (a local context). For example, compare the difference between a calculation with automatic precision for intermediate results to the same calculation with fixed precision (obtained by making $MinPrecision ==$MaxPrecision ).

In[1]:= SetPrecision[(1 + Exp[Sqrt[2] + Sqrt[3]])/2^25, 32]

Out[1]= 7.226780742612584668840452114476*10^-7

In[2]:=
Block[{$MinPrecision = 32,$MaxPrecision = 32},
SetPrecision[(1 + Exp[Sqrt[2] + Sqrt[3]])/2^25, 32]]

Out[2]= 7.2267807426125846688404521144759*10^-7


Why two results are different, despite the fact that precision was set to 32 digits in both expression ? And what is "automatic precision" ?
Edit: user "rcollyer" points out that

running Precision on the two results gives 31.5935 and 32..

-

I don't think that SetPrecision[x,p] simply returns a version of x with precision p. Rather, it sets all numeric types in x to precison p and then evaluates x. This is important, if we want SetPrecision to work on symbolic arguments. For example,

SetPrecision[2 x, 4]


2.000 x

Thus, the following computation need not yield 4:

Precision[SetPrecision[Sqrt[2], 4]]


4.30103

In fact, this is equivalent to

Precision[Sqrt[SetPrecision[2, 4]]]


4.30103

Of course, Sqrt[SetPrecision[2, 4]] is subject to precision tracking using significance arithmetic. Thus, we don't expect it's precision to be 4.

On the other hand, setting $MaxPrecision==$MinPrecision forces all results to have this common value.

-
why is Precision[SetPrecision[Sqrt[2], 4]] results in precision different than 4 ??? – newprint Jun 25 '12 at 5:54
@newprint I added one line. Does that help? – Mark McClure Jun 25 '12 at 10:38
SetPrecision does just as you claim (so you can remove the "I don't think that" part if you like). – Daniel Lichtblau Jun 25 '12 at 16:33
@DanielLichtblau and Mark, what about Precision[Sqrt[SetPrecision[100, 10]]] not returning the same result as Precision[SetPrecision[Sqrt[100], 10]]? – Rojo Jun 28 '12 at 13:24
@Rojo It would be easier to answer if you stated why you beleive they should be equal (or whatever expectation they did not meet). The second is clearly going to be 10 up to machine epsilon or so. That's because you set it and immediately evaluated it. The first sets the precision of the argument of Sqrt. The precision of the result will then depend on first order estimates of error of Sqrt, evaluated at 10. – Daniel Lichtblau Jun 28 '12 at 15:20