I am trying to understand how WorkingPrecision works, and in general how very small/large numbers are to be handled. Let me preface I probably do not have sufficient theoretical knowledge on floating\arbitrary precision numbers: please do not hesitate to suggest a good book to understand the topic from the applications point of view.

Anyhow, I am dealing with the complete elliptic integral of the first kind, EllipticK, which I believe displays a logarithmic divergence for $k \to 1$.

If I attempt

     rooteK2[a_] := 
      NSolve[{EllipticK[k] == a, 0 <= k <= 1}, k, WorkingPrecision -> 200]

I get no solutions.

Yet If I try

    rootlog[a_] := NSolve[Log[x] == -a, x, WorkingPrecision -> 100]

I get

  {{x -> 1.1354838653147360985409388750662484019574316100903188426715526\

which I find surprising, as I believe the divergence is similar (for $x \to 1$ and $x \to 0$ in the elliptic integral and logarithmic function respectively).

Further, If I try


I obtain


but one more digit


and I get


On the other hand

  Log[1 - 0.99999999999999999]



and not Infinity. Further, in the example above with NSolve, numbers such $10^-4343$ were seemingly handled, certainly smaller than $1 - 0.99999999999999999$.

I would be really interested to understand the difference and learn more abo about accuracy, thanks a lot, much appreciated.

EDIT Following Bob Hanlon's comments below, I would like to clarify I am using version 11.2. If I issue e.g.


I do get an answer $\approx 23.26086 \dots$.

Yet, if I try to back-calculate the argument of EllipticK used just above via rooteK2[23.26086`100] (as defined at the beginning of the post) I get no answer (differently from version 12.2).

  • 2
    $\begingroup$ EllipticK[0.99999999999999999] The argument is a machine number so the calculation is done with machine precision. Specify a precision to use arbitrary-precision. EllipticK[0.99999999999999999`100] or EllipticK[SetPrecision[1-10^-17, 100]] or N[EllipticK[1-10^-17], 100] $\endgroup$
    – Bob Hanlon
    May 2, 2020 at 15:25
  • $\begingroup$ @BobHanlon, that is understood, thanks a lot. Yet, when I look for the root with rooteK2[a_] := NSolve[{EllipticK[k] == a, 0 <= k <= 1}, k, WorkingPrecision -> 200] still do not get a result for rooteK2[50] nor rooteK2[50.`300] , could you please clarify further, thanks for the patience $\endgroup$
    – Smerdjakov
    May 2, 2020 at 16:48
  • $\begingroup$ Using your suggestion, I can calculate values for arguments of the elliptic functions extremely close to 1. I would also expect NSolve to be able to back-calculate those. $\endgroup$
    – Smerdjakov
    May 2, 2020 at 16:59
  • $\begingroup$ rooteK2[50.`200] works for me with version 12.1. What version are you using? $\endgroup$
    – Bob Hanlon
    May 2, 2020 at 16:59
  • 1
    $\begingroup$ A common ref for FP is Goldberg; but almost any numerical analysis textbook since the 1990s would probably have a (shorter) chapter on FP. More extensive treatments are Higham (on application to numerical analysis) and Overton (on the IEEE 754 standard). Not sure either of those are what you're looking for. "Arbitrary precision" is a Wolfram thing (see documentation). It's like FP but somewhat different. $\endgroup$
    – Michael E2
    May 3, 2020 at 18:15


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.