
Calcium: computing in exact real and complex fields Fredrik Johansson∗ Abstract Calcium is a C library for real and complex numbers in a form suitable for exact algebraic and symbolic computation. Numbers are represented as elements of fields Q(a1,...,an) where the extensions numbers ak may be algebraic or transcendental. The system combines efficient field operations with automatic discovery and certifi- cation of algebraic relations, resulting in a practical computational model of R and C in which equality is rigorously decidable for a large class of numbers. 1 Introduction A field K is said to be effective if its elements can be enumerated and the operations +, , , /, = are computable. Examples include the rationals Q, finite fields F , and the { − · } q algebraic numbers Q. The fields of real and complex numbers R and C are notably non-effective, even when restricted to so-called computable numbers (a real number x is said to be computable if there is a program which, given n, outputs some x Q with x x < 2 n). The n ∈ | − n| − problem is that equality is only semi-decidable: we can in general prove x = y, but not 6 x = y, as a consequence of the halting theorem. Nevertheless, as the example of Q shows, we can hope for an equality test at least for some numbers within a suitable algebraic framework. This paper presents Calcium,1 a C library for exact computation in R and C. Num- bers are represented as elements of fields Q(a1, . , an) where the extension numbers ak are defined symbolically. The system constructs fields and discovers algebraic relations automatically, handling algebraic and transcendental number fields in a unified way. It is capable of deciding equality for a wide class of numbers which includes Q as a subset. We show a few basic examples, here using a Python wrapper: >>> (pi**2 - 9) / (pi + 3) arXiv:2011.01728v1 [cs.MS] 3 Nov 2020 0.141593 {a-3 where a = 3.14159 [Pi]} >>> phi = (sqrt(5)+1)/2; (phi**100 - (1-phi)**100)/sqrt(5) 3.54225e+20 {354224848179261915075} >>> i**i - exp(pi / (sqrt(-2)**sqrt(2))**sqrt(2)) 0 >>> log(sqrt(2)+sqrt(3)) / log(5+2*sqrt(6)) 0.500000 {1/2} >>> erf(4*atan(ca(1)/5) - atan(ca(1)/239)) + erfc(pi/4) 1 >>> -1e-12 < exp(pi*sqrt(163)) - 262537412640768744 < -1e-13 True ∗ Inria Bordeaux and Institut Math. Bordeaux – [email protected] 1Pronounced “kalkium” to distinguish it from the chemical element. Calcium is free and open source (LGPL 2.1+) software. The source repository is https://github.com/fredrik-johansson/calcium and the documentation is available at http://fredrikj.net/calcium/. 1 In the first example, the field is Q(a) where a = π, and the element is a 3. The − numerical approximation (x 0.141593) is computed to desired precision on demand, for ≈ example when printing or evaluating a numerical predicate. Examples 2–5 were chosen so that the field of the result simplifies to Q. Such examples are within the scope of the expression simplification tools in computer algebra systems like Mathematica and Maple.2 The key difference is that we work with more structured representations; we also handle numerical evaluation and predicates rigor- ously. Our approach is inspired by various earlier implementations of Q and by theoretical work on transcendental fields. This paper is structured as follows. Section 2 presents our high-level strategy for exact computation, described at a general level without reference to low-level implementation details. Section 3 discusses the architecture of Calcium. Section 4 relates our strategy to earlier work and presents some benchmark results. 2 Computing in subfields of C To simulate R and C, we may start with Q and lazily extend the field with new numbers ak as they arise in computations. A general way to compute in such extension fields of Q is in terms of quotient rings and their fields of fractions (henceforth formal fields). In the following, we assume that a1, . , an is a finite list of complex numbers. We let X ,...,X denote independent formal variables, we let µ : Q[X ,...,X ] C denote 1 n 1 n → the evaluation homomorphism induced by the map X a , and we define k 7→ k I := ker µ = f Q[X ,...,X ] : f(a , . , a ) = 0 { ∈ 1 n 1 n } as the ideal of all algebraic relations among a1, . , an over Q. Theorem 1. Assume that I is known (in the sense that an explicit list of generators I = f ,...,f is known). Then h 1 mi Q Q K := (a1, . , an) ∼= Kformal := Frac( [X1,...,Xn]/I) is an effective subfield of C. Proof. The isomorphism is obvious. Decidability of “=” in the formal field follows from p r the fact that we can compute a Gr¨obner basis for I. Given formal fractions q and s with p,q,r,s Q[X ,...,X ], we can consequently decide whether ps qr mod I. Indeed, ∈ 1 n ≡ we can also decide whether q,s 0 mod I and thereby ensure that the fractions define 6≡ numbers in the first place. Some easy special cases are worth noting: • The trivial field K = Q (take n = 0). • Transcendental number fields K = Q(a1, . , an) where the numbers a1, . , an are algebraically independent over Q. • Algebraic number fields K = Q(a) = Q[X]/ f(X) where a is an algebraic number ∼ h i with minimal polynomial f. 2Open source systems tend to perform much worse: SymPy, for example, fails to simplify examples 3–5. Maple curiously also fails to simplify example 3. 2 The general case is a mixed field in which the extension numbers may be algebraic or transcendental and algebraically dependent or independent in any combination. Example 1. Q(log(i),π,i) = Frac(Q[X , X , X ]/I) where I = 2X X X , X2 + 1 . ∼ 1 2 3 h 1 − 2 3 3 i Theorem 1 solves the arithmetic part of computing in finitely generated subfields of C, at least up to practical issues such as the complexity of multivariate polynomial arithmetic and Gr¨obner basis computations. The crucial assumption made in Theorem 1, however, is that the ideal I is known. In general, finding I is an extremely hard problem. For Q Q Q Q example, although (π) ∼= (X1) and (e) ∼= (X2), it is an open problem to prove Q Q (π, e) ∼= (X1, X2). There are specific instances where we can prove algebraic indepen- dence (the Hermite-Lindemann-Weierstrass theorem, Baker’s theorem, transcendence of 1 isolated numbers such as Γ( 4 ), results for E-functions [11], etc.), but we typically only Q Q have conjectures. Most famous (and implying (π, e) ∼= (X1, X2) as a special case) is: Conjecture 2 (Schanuel’s conjecture). If z1,...,zn are linearly independent over Q, then z1 zn Q(z1,...,zn, e ,...,e ) has transcendence degree at least n over Q. Thus, in general, we can only determine I conjecturally. We address this limitation below in section 2.2. 2.1 Defining extension numbers We stress that we cannot simply input I as a way to define the extension numbers a1, . , an, since this does not give enough information about the embedding (that is, µ) in C. We are not interested in computing in an abstract algebraic structure but in a concrete model of R and C where we can do (at least) the following: • Evaluate the complex conjugation map z z. → • Evaluate numerical ordering relations (x<y, x < y , etc.). | | | | • Exclude singularities (e.g. division by zero) and choose well-defined branches of multivalued functions. We therefore need a symbolic way to define extension numbers a1, . , an so that they are explicitly (numerically) computable, and we need to construct I from this symbolic data rather than vice versa. The following types of extensions are useful: • Absolute algebraic: a is a fixed algebraic constant a Q, for example i, √2, e2πi/3, ∈ or [a5 a 1 = 0; a 1.17]. Such a constant can be defined canonically by its − − ≈ minimal polynomial over Q together with an isolating ball for a root. • Relative algebraic: a is defined by an equation am/n = c with c C, or P (a) = 0 ∈ with P C[X] together with an isolating complex ball for a root. ∈ • Transcendental: a is a symbolic transcendental (or conjecturally transcendental) z w constant (π, γ, etc.) or function (e , log(z), z , Γ(z), Jν (z), etc.) evaluated at some point. • Black-box computable: a is defined by a program for numerical evaluation in ball arithmetic. (We will not be able to prove algebraic relations except self-relations like a a = 0.) − 3 Calcium presently supports extension numbers of the first three types. We repre- sent algebraic and transcendental extensions in the usual way as symbolic expressions f(z1,...,zp). The arguments z1,...,zp are real or complex numbers which may belong to different fields, say z Q(b , . , b ), z Q(c ,...,c ), etc. 1 ∈ 1 r 2 ∈ 1 s Each extension number defines a computable number through recursive numerical eval- uation of the symbolic function and its arguments in arbitrary-precision ball arithmetic. This is at least true in principle assuming that we can decide signs at discontinuities. An important improvement over many symbolic computation systems is that we exclude non- numerical extension numbers: for example, when adding log(z) as an extension number, we must be able to prove z = 0. We fix principal branches of all multivalued functions. 6 This is only a starting point: we can imagine other classes of extensions (periods, solutions of implicit transcendental equations, etc.).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages17 Page
-
File Size-