Apparent inconsistencies in the operation of N[]

There are many good discussions of precision and N. But, I couldn't find the following succinctly stated in other answers:

  1. Expressions that mix machine precision numbers and arbitrary precision numbers always evaluate to a machine number. You can think of machine precision numbers as being the lowest possible precision one can use.

  2. Expressions evaluated using machine precision numbers have no error tracking. The result will not give any indication of which digits in the result are accurate, and it is entirely possible that none of the digits are accurate.

  3. Expressions evaluated using only arbitrary precision numbers and exact numbers (i.e., no machine precision numbers) will have their numerical errors tracked during the evaluation process, and the result will be given with a conservative estimate of the precision achieved accounting for those numerical errors.

  4. If one uses N[expr, prec], where prec is a number (not the variable MachinePrecision), then Mathematica will attempt to return a result with precision prec. If the numerical error tracking process decides that the error has gotten too big to achieve the desired precision goal, than it will increase the working precision in order to achieve the desired precision goal. The amount of extra precision that Mathematica will use is limited by the variable $MaxExtraPrecision.

Now, @MichaelE2 has already explained the main issues, but let me repeat them below:

  1. For your first table you use N[exact], and so only machine precision is used, and a naive machine precision computation of your expression encounters underflow, and so you get Indeterminate in these cases.

  2. For your second table, you use N[exact, 10], and so Mathematica works extra hard by using an increased working precision so that it can return a result with a correct precision of 10.

  3. For you third and fourth tables, your table iterator actually evaluates to a machine precision number, and so what is evaluated is N[machineNumber] and N[machineNumber, 10]. Since the number is already a machine number, N doesn't do anything.

  4. For your last evaluation, you again use N[exact, 10] and so Mathematica returns a result correct to 10 digits.


The probable reason is underflow or internal machine rounding error. First evaluate to arbitrary precision:

Table[N@N[Log[DedekindEta[(I b*1/1000)/(2 π)]], $MachinePrecision], {b, 1, 5}]
(* {-1640.56, -818.441, -544.488, -407.554, -325.419}  *)

Note that for the iterator {b, 1, 5, 0.5}, the values of b are machine-precision numbers:

Table[b, {b, 1, 5, 0.5}]
(*  {1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5.}  *)

The corresponding values of Log@DedekindEta evaluate to Indeterminate before N has a chance to work on the values:

Table[N[Log[DedekindEta[(I b*1/1000)/(2 π)]], 32], {b, 1, 5, 0.5}]
(*
  {Indeterminate, Indeterminate, Indeterminate, -654.059, -544.488, 
   -466.235, -407.554, -361.92, -325.419}
*)

DedekindEta[(I 1/1000)/(2 π)]] 

(*

0

*)

and then N@Log[%] gives Indeterminate.

(Version 10.4.)