In this section, facilities for computing with real and complex-valued functions defined are summarised. Since a real or complex number is represented in the computer by a finite approximation, the functions are designed to produce results up to some specified precision. For example, if computations are to be performed over the complex field ℂ with a precision of n digits, the user first creates an ambient complex field with n digits of precision. The functions and operations described here will then work to that precision given any elements belonging to that version of ℂ. The precision n can be set to a very large positive value and so calculations with millions of digits can be performed.
The packages MPFR and MPC are used to provide arbitrary precision real and complex arithmetic. These are principally developed by INRIA (particularly Paul Zimmermann originally) and Andreas Enge, with MPC being based on MPFR, and MPFR itself being based on GMP. These libraries allow guaranteed rounding according to ANSI/IEEE-754 standards in arbitrary precision upon zero-extending the input. The number of implemented functions is not overly large, but handles the basics (such as the trigonometric functions and their inverses).
Magma contains implementations of a number of other numerical functions, which are described in the Real and Complex Fields section of the Handbook. Examples are Bessel functions, polylogarithms, hypergeometric functions, Dawson's integral, and Weber's functions. The implementation of these largely follows PARI code from the mid 90s. Furthermore, some functions related to elliptic curves, such as the elliptic logarithm and exponential, have been re-implemented from scratch in a highly efficient manner. Another example is Θ-functions suitable for working with Rosenhain invariants for analytic Jacobians of hyperelliptic curves (implemented by Paul van Wamelen).
Quite recently, the numerical facilities of Magma were extended to include some rudimentary methods for numerical linear algebra. These are based on the RQ decomposition of a matrix which is the reverse of the more traditional QR decomposition, as Magma is row-based in its view of matrices. The functionality currently includes:
The user can specify a tolerance to be used, or this can be computed automatically via an analysis of a condition number.
Such numerical linear algebra methods are used internally in various places, such as when dealing with lattices over the real numbers, which occur in class and unit group calculations for number fields.
An implementation by Xavier Gourdon of Schönage's splitting circle method is used to find the complex roots of a polynomial to high accuracy. The Graeffe process is used to find suitable splitting circles, and given exact input, the method can then be iterated so as to determine the roots to within the precision of the ambient real field. Other algorithms include Laguerre's method and Newton–Raphson, which may have different time/accuracy trade-offs, and indeed are more useful for non-exact input.
The real roots of a polynomial are found using a version of the so-called “Uspensky's algorithm”, based on Vincent's theorem, to isolate the roots. This uses translations of the original polynomial, as opposed to Sturm-based methods that use derivatives.
Given a complex number α and a target degree, Magma uses the LLL algorithm to determine a “best-fit” polynomial of the given degree for α. This now uses Damien Stehle's implementation of LLL, proceeding by finding a (near) linear relation between powers of α. More generally, a best-fit linear relation can be found for a sequence of complex numbers.
Other algorithms in Magma use real and/or complex approximations to determine an exact result. One example of this is the computation of Heegner points on rank 1 elliptic curves (over the rationals), where in conjunction with 12-descent, lattice-based methods can be used to recognise a rational point with 4600 digits using only 35 digits of precision.
Some basic functionality is provided for integration, such as Simpson, trapezoidal, and Romberg quadrature. Interpolation is possible via the use of Neville's algorithm, and computing numerical derivatives is also available.