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:
- Is this problem decidable? I found that Richardson's theorem establishes the undecidability of a similar problem.
- If the problem is decidable, is there a known algorithm and some (at least partial) implementation of it?
- 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.