14
$\begingroup$

Let $E$ be the set of elementary expressions, defined as the smallest set of mathematical expressions such that $1 \in E$, and if $a,b \in E$ then $a + b$, $a - b$, $ab$, $a/b$, $\exp(a)$, $\log(a)$ all belongs to $E$ (note that expressions such as $a/0$ or $\log(0)$ are fine, although they do not have a numerical value).

This problems often pop ups:

Problem. Given an expression $f$ in $E$ and a natural number $n$, find the first $n$ decimal digits of the numerical evaluation of $f$ (real and complex part).

Note that $E$ contains expressions for $e = \exp(1)$, $i = \exp(\log(-1)/2)$, $\pi = -i\log(-1)$, and many "elementary" mathematical constants. Also, assume a NaN evaluation for expressions like $1/0$.

My questions are the following:

  1. Is this problem decidable? I found that Richardson's theorem establishes the undecidability of a similar problem.
  2. If the problem is decidable, is there a known algorithm and some (at least partial) implementation of it?
  3. If the problem is undecidable, what is the main obstruct and are there some ways to go around it? Again implementation of (heuristic?) algorithms are welcome.

Thanks

Update. The current answers solve the question if the problem is decidable (yes, but under Schanuel's conjecture). The only thing that prevents me from accepting an answer, is that I would like to know about implementations of the algorithm. Since I often encounter this problem in practice, is there some software that (assuming Schanuel's conjecture) I can run to solve the problem for a certain expression? (Of course I can do my own reasoning about the number of correct digits given by certain software and how the errors propagate, but I would like something that automatically do that.)

Second update. In light of Aurel's comments, I point out that the software Calcium seems to do the job. More precisely, according to the documentation, the function

char *ca_get_decimal_str(const ca_t x, slong digits, ulong flags, ca_ctx_t ctx)

returns a decimal approximation of x with precision up to digits. The output is guaranteed to be correct within 1 ulp in the returned digits, but the number of returned digits may be smaller than digits if the numerical evaluation does not succeed.

$\endgroup$
10
  • $\begingroup$ Doesn't Richardson's theorem immediately give that your problem isn't decidable, with $\sin x = \frac{e^{ix} - e^{-ix}}2$? $\endgroup$ Commented Feb 14 at 11:12
  • $\begingroup$ Also see Tarski's exponential function problem $\endgroup$ Commented Feb 14 at 11:15
  • 4
    $\begingroup$ I don't understand the downvotes. This is an interesting question, which turns out to be equivalent to a difficult open problem, and although it is easily confused with Richardson's theorem, it is a distinct problem. $\endgroup$ Commented Feb 14 at 14:39
  • 1
    $\begingroup$ About your update: you may be interested in Calcium. Although it does not (yet?) have a complete implementation of Richardson's algorithm, it can decide some nontrivial equalities. $\endgroup$
    – Aurel
    Commented Feb 15 at 22:47
  • 1
    $\begingroup$ @LSpice, you misunderstood my example. Perhaps the true actual value would be 3.269999999234 etc., but the point is that if Calcium returned 3.270000 it would be highly accurate, but the digits would not be correct. That is, having an accurate result is not the same as having digits correct to that place. Or similarly, if the true value was 3.27000000023, then 3.269999999 would also be highly accurate, but with wrong digits. $\endgroup$ Commented Feb 17 at 19:40

3 Answers 3

12
$\begingroup$

There is a certain confusion in the answers, so let me try to dispel this confusion.

There are two different issues here. One is “computing an approximation with arbitrary precision” and one is “computing correct digits”.

The first, “computing an approximation with arbitrary precision”, is certainly possible algorithmically (proviso the quantity is indeed a real or complex number), as Alexandre Eremenko points out in his answer. However, as Joel David Hamkins points out in a comment to this answer, computing arbitrarily precise approximations (≈being a computable real number) is not the same as computing guaranteed correct digits, essentially because deciding whether a computable real number is $\geq 0$ or $\leq 0$ (even if both answers are deemed acceptable in case of exact equality) is not decidable.

However, for the specific numbers being considered here, it turns out that equality is decidable, if we assume Schanuel's conjecture holds, as I explain in the answer to this question (this is also a result by Richardson, but this one is positive). Now if we can decide equality and we can compute with arbitrary precision, then we can indeed compute guaranteed correct digits. So the answer to the question is positive provided we assume Schanuel's conjecture. More precisely, there is a (fairly explicit) algorithm which will compute guaranteed correct digits if it terminates, and which will always terminate if Schanuel's conjecture holds.

$\endgroup$
7
  • $\begingroup$ Gro-Tsen, are you saying that my answer is incorrect or confused? It seems that the digit problem is Turing equivalent to the constant problem, and this is open, although you point out that both would be decidable under Schanuel's conjecture. $\endgroup$ Commented Feb 14 at 14:56
  • 1
    $\begingroup$ @JoelDavidHamkins I'm not saying either way, because I'm not sure after reading the MathWorld and Wikipedia articles what the constant problem actually says (specifically, are there indeterminates in the expression or is it just about real numbers?). But note that there's no contradiction between “it's decidable under Schanuel's conjecture” and “it's an open question whether it's decidable”. (At best, the MathWorld and Wikipedia article are confusing for not mentioning — or comparing with — Richardson's positive result which I cited.) $\endgroup$
    – Gro-Tsen
    Commented Feb 14 at 15:01
  • $\begingroup$ Oh, I agree with that point. But isn't it clear that the constant problem is exactly the case where there are no indeterminates? This was the confusion (between the constant problem and Richardson's theorem) that I had taken myself to be dispelling. $\endgroup$ Commented Feb 14 at 15:04
  • 1
    $\begingroup$ @JoelDavidHamkins The MathWorld and Wikipedia articles suggest that the “constant problem” allows “taking limits”, which suggests that there must be some kind of indeterminate on which to take the limit. But again, I just don't understand what they're saying. However, Richardson's paper is pretty clear that he has a positive result, conditional to Schanuel's conjecture, for deciding equality of “elementary numbers”, which are an algebraically closed field closed under $\exp$, $\sin$ and $\cos$ (and, if I understand his definitions, $\log$ as well). $\endgroup$
    – Gro-Tsen
    Commented Feb 14 at 15:29
  • 1
    $\begingroup$ @JoelDavidHamkins My understanding is that Schanuel's conjecture is generally believed to be true but so vastly out of reach of current techniques that it is something of a holy grail. (A similar “very general, generally believed but ridiculously out of reach” conjecture would be Schinzel's hypothesis H.) $\endgroup$
    – Gro-Tsen
    Commented Feb 16 at 22:22
11
$\begingroup$

This problem is Turing equivalent to the constant problem (see also Wikipedia-constant problem), but it is open whether this problem is decidable.

The constant problem is the problem of determining whether a given constant expression $E$ (in a suitable language) is zero.

This is different from Richardson's theorem, which in contrast is concerned with the problem of determining whether a given expression $E(x)$ with free variable $x$ is the zero function, that is, zero for all values of $x$. Richardson's theorem shows that this problem is not computably decidable.

Your digit problem is at least as hard as the constant problem, since as Kostya mentions in his answer, a given constant expression $E$ is zero if and only if $1-E^2$ starts with 1.0.

Conversely, the constant problem is at least as hard as the digit problem. To see this, notice first that the digit problem is computable from the order-relation problem, determining whether $E<F$ for constant expressions. This is because you can learn the digits of $E$ by comparing it with suitable rational expressions. And the $E<F$ problem is equivalent to deciding positivity $0<E$. But with an oracle for the constant problem, given $E$ we can first decide whether $E=0$ or not, and if not, compute approximations well enough to determine the sign. (Thanks for the comment of Aurel.)

So your problem is equivalent to the constant problem. But according to Wolfram, it is open whether the constant problem is computably decidable.

$\endgroup$
12
  • $\begingroup$ Perhaps a clever person can show that the digit problem is Turing equivalent to the constant problem? $\endgroup$ Commented Feb 14 at 13:45
  • 1
    $\begingroup$ Can't you do something like this? Suppose you can solve the constant problem. Then you can decide the sign of any expression: first test for zero, and if not zero compute a good enough approximation to determine the sign. Finally the $k$-th digit (given the previous ones) being equal to a certain value is equivalent to a certain inequality about the expression. $\endgroup$
    – Aurel
    Commented Feb 14 at 14:04
  • $\begingroup$ Yes, I think that works! (I was also just thinking along similar lines.) $\endgroup$ Commented Feb 14 at 14:06
  • $\begingroup$ Do we determine the sign of an expression $E$ by asking whether the imaginary part of $\log(E)$ is $0$? Would twice the imaginary part be $E-\exp(-\log(E))$? Nope. How could we extract it ? $\endgroup$ Commented Feb 14 at 14:20
  • 1
    $\begingroup$ @ClaudeChaunier Or perhaps you are simply asking why these numbers are computable numbers? This is because of the kind of reasoning in Alexandre's answer, which gives approximate values to the expressions as accurate as desired, that is, within a known $\epsilon$. The key fact to keep in mind, though, is that having accurate approximations is not the same as having exact digits, since perhaps the value is close to a boundary where the digits flip over with carries, and you won't know yet which side you're on. $\endgroup$ Commented Feb 14 at 14:34
5
$\begingroup$

Edited after the comment of Joel David Hamkins. The "correct $n$-th digit of a real number, of of real and imaginary part of a complex number is ill defined. For example, what is the $n$-th digit of the number 1=0.999999...? What is the "correct 5-th digit"?

But you can approximate your numbers with any given accuracy, and there are simple algorithms for this. The algorithms for $a\pm b$, $ab$ and $a/b$ we study in elementary school while for $\exp(a),\log a$ one can use power series, or rational approximation.

The difference with Richardson's theorem is that he considers exact equality, while you ask only about $n$ digits. So you cannot always determine that such an expression is $=0$, but you can determine whether the first 100 digits are $0$.

Moreover, for all these functions there exist algorithms which work with polynomial speed in $n$, even with the speed $n^{1+\epsilon}$. For addition/subtraction this is evident, for multiplication/division these are fast multiplication algorithms (based of fast Fourier transform), while for $\exp$ and $\log$ these are algorithms based on AGM.

See, for example, Donald Newman, Rational approximation versus fast computer methods. Lectures on approximation and value distribution, pp. 149–174, Sém. Math. Sup., 79, Presses Univ. Montréal, Montreal, QC, 1982,

where all mentioned algorithms are explained.

$\endgroup$
4
  • 11
    $\begingroup$ For exact digits, you can't even add $a+b$. If you know lots of digits for $a$ and $b$ exactly, then to get exact digits for $a+b$, you might have to know whether there is a carry or not, which might not yet be revealed in what you know about $a$ and $b$ (and might never be revealed). e.g. $a=0.444444\ldots$ and $b=0.555555\ldots$. This issue is related to a certain error that Turing had made in his 1936 paper about computable numbers. See jdh.hamkins.org/alan-turing-on-computable-numbers. $\endgroup$ Commented Feb 14 at 13:09
  • 1
    $\begingroup$ By "$n$ exact digits" I mean that you can compute the number with accuracy $10^{-n}$. You are right, of course, one cannot literally obtain exact digits. Actually since 0.9999...=1, is the same real number, "exact digits of a real number are not even defined! $\endgroup$ Commented Feb 15 at 4:16
  • 1
    $\begingroup$ @AlexandreEremenko "exact digits of a real number are not even defined!" I entirely disagree with this assertion. The decimal representation of real numbers can be uniquely defined by not allowing an infinite sequence of 9 digits at the end. $\endgroup$
    – rosan98
    Commented Feb 15 at 10:42
  • $\begingroup$ rosan98: You can interpret my answer in either way. See comment of Joel Hamkins. $\endgroup$ Commented Feb 15 at 11:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .