Complex balls
Arbitrary precision complex ball arithmetic is supplied by Arb which provides a ball representation which tracks error bounds rigorously. Complex numbers are represented in rectangular form $a+bi$ where $a,b$ are arb
balls.
The Arb complex field is constructed using the AcbField
constructor. This constructs the parent object for the Arb complex field.
We define
ComplexField = AcbField
so that one can construct the Arb complex field parent using ComplexField
instead of AcbField
.
The types of complex boxes in Nemo are given in the following table, along with the libraries that provide them and the associated types of the parent objects.
Library | Field | Element type | Parent type |
---|---|---|---|
Arb | $\mathbb{C}$ (boxes) | acb | AcbField |
All the complex field types belong to the Field
abstract type and the types of elements in this field, i.e. complex boxes in this case, belong to the FieldElem
abstract type.
Complex ball functionality
The complex balls in Nemo implement the AbstractAlgebra.jl field interface.
https://nemocas.github.io/AbstractAlgebra.jl/fields.html
Below, we document the additional functionality provided for complex balls.
Complex field constructors
In order to construct complex boxes in Nemo, one must first construct the Arb complex field itself. This is accomplished with the following constructor.
AcbField(prec::Int)
Return the Arb complex field with precision in bits prec
used for operations on interval midpoints. The precision used for interval radii is a fixed implementation-defined constant (30 bits).
Here is an example of creating an Arb complex field and using the resulting parent object to coerce values into the resulting field.
Examples
CC = ComplexField(64)
a = CC("0.25")
b = CC("0.1")
c = CC(0.5)
d = CC(12)
Note that whilst one can coerce double precision floating point values into an Arb complex field, unless those values can be represented exactly in double precision the resulting ball can't be any more precise than the double precision supplied.
If instead, values can be represented precisely using decimal arithmetic then one can supply them to Arb using a string. In this case, Arb will store them to the precision specified when creating the Arb complex field.
If the values can be stored precisely as a binary floating point number, Arb will store the values exactly. See the function isexact
below for more information.
Constructors
Nemo.onei
— Method.onei(r::AcbField)
Return exact one times $i$ in the given Arb complex field.
Examples
CC = ComplexField(64)
c = onei(CC)
Basic functionality
The following basic functionality is provided by the default Arb complex field implementation in Nemo, to support construction of generic rings over complex fields. Any custom complex field implementation in Nemo should provide analogues of these functions along with the usual arithmetic operations.
parent_type(::Type{acb})
Gives the type of the parent object of an Arb complex field element.
elem_type(R::AcbField)
Given the parent object for an Arb complex field, return the type of elements of the field.
mul!(c::acb, a::acb, b::acb)
Multiply $a$ by $b$ and set the existing Arb complex field element $c$ to the result. This function is provided for performance reasons as it saves allocating a new object for the result and eliminates associated garbage collection.
addeq!(c::acb, a::acb)
In-place addition adds $a$ to $c$ and sets $c$ to the result. This function is provided for performance reasons as it saves allocating a new object for the result and eliminates associated garbage collection.
deepcopy(a::acb)
Return a copy of the Arb complex field element $a$, recursively copying the internal data. Arb complex field elements are mutable in Nemo so a shallow copy is not sufficient.
Given the parent object R
for an Arb complex field, the following coercion functions are provided to coerce various elements into the Arb complex field. Developers provide these by overloading the call
operator for the complex field parent objects.
R()
Coerce zero into the Arb complex field.
R(n::Integer)
R(f::fmpz)
R(q::fmpq)
Coerce an integer or rational value into the Arb complex field.
R(f::Float64)
R(f::BigFloat)
Coerce the given floating point number into the Arb complex field.
R(f::AbstractString)
R(f::AbstractString, g::AbstractString)
Coerce the decimal number, given as a string, into the Arb complex field. In each case $f$ is the real part and $g$ is the imaginary part.
R(f::arb)
Coerce the given Arb real ball into the Arb complex field.
R(f::acb)
Take an Arb complex field element that is already in an Arb field and simply return it. A copy of the original is not made.
Here are some examples of coercing elements into the Arb complex field.
RR = RealField(64)
CC = ComplexField(64)
a = CC(3)
b = CC(QQ(2,3))
c = CC("3 +/- 0.0001")
d = CC("-1.24e+12345")
f = CC("nan +/- inf")
g = CC(RR(3))
In addition to the above, developers of custom complex field types must ensure that they provide the equivalent of the function base_ring(R::AcbField)
which should return Union{}
. In addition to this they should ensure that each complex field element contains a field parent
specifying the parent object of the complex field element, or at least supply the equivalent of the function parent(a::acb)
to return the parent object of a complex field element.
Basic manipulation
Base.isfinite
— Method.isfinite(x::acb)
Return
true
if $x$ is finite, i.e. its real and imaginary parts have finite midpoint and radius, otherwise returnfalse
.
Nemo.isexact
— Method.isexact(x::acb)
Return
true
if $x$ is exact, i.e. has its real and imaginary parts have zero radius, otherwise returnfalse
.
Nemo.isint
— Method.isint(x::acb)
Return
true
if $x$ is an exact integer, otherwise returnfalse
.
Base.isreal
— Method.isreal(x::acb)
Return
true
if $x$ is purely real, i.e. having zero imaginary part, otherwise returnfalse
.
Base.real
— Method.real(x::acb)
Return the real part of $x$ as an
arb
.
Base.imag
— Method.imag(x::acb)
Return the imaginary part of $x$ as an
arb
.
Nemo.accuracy_bits
— Method.accuracy_bits(x::acb)
Return the relative accuracy of $x$ measured in bits, capped between
typemax(Int)
and-typemax(Int)
.
Examples
CC = ComplexField(64)
a = CC("1.2 +/- 0.001")
b = CC(3)
isreal(a)
isfinite(b)
isint(b)
c = real(a)
d = imag(b)
f = accuracy_bits(a)
Containment
It is often necessary to determine whether a given exact value or box is contained in a given complex box or whether two boxes overlap. The following functions are provided for this purpose.
Nemo.overlaps
— Method.overlaps(x::acb, y::acb)
Returns
true
if any part of the box $x$ overlaps any part of the box $y$, otherwise returnfalse
.
Nemo.contains
— Method.contains(x::acb, y::acb)
Returns
true
if the box $x$ contains the box $y$, otherwise returnfalse
.
Nemo.contains
— Method.contains(x::acb, y::Integer)
Returns
true
if the box $x$ contains the given integer value, otherwise returnfalse
.
Nemo.contains
— Method.contains(x::acb, y::fmpz)
Returns
true
if the box $x$ contains the given integer value, otherwise returnfalse
.
Nemo.contains
— Method.contains(x::acb, y::fmpq)
Returns
true
if the box $x$ contains the given rational value, otherwise returnfalse
.
The following functions are also provided for determining if a box intersects a certain part of the complex number plane.
Nemo.contains_zero
— Method.contains_zero(x::acb)
Returns
true
if the box $x$ contains zero, otherwise returnfalse
.
Examples
CC = ComplexField(64)
x = CC("1 +/- 0.001")
y = CC("3")
overlaps(x, y)
contains(x, y)
contains(y, 3)
contains(x, ZZ(1)//2)
contains_zero(x)
Comparison
Nemo provides a full range of comparison operations for Arb complex boxes.
In addition to the standard comparisons, we introduce an exact equality. This is distinct from arithmetic equality implemented by ==
, which merely compares up to the minimum of the precisions of its operands.
Base.isequal
— Method.isequal(x::acb, y::acb)
Return
true
if the boxes $x$ and $y$ are precisely equal, i.e. their real and imaginary parts have the same midpoints and radii.
A full range of ad hoc comparison operators is provided. These are implemented directly in Julia, but we document them as though only ==
were provided.
Function |
---|
==(x::acb, y::Integer) |
==(x::Integer, y::acb) |
==(x::acb, y::fmpz) |
==(x::fmpz, y::acb) |
==(x::arb, y::fmpz) |
==(x::fmpz, y::arb) |
==(x::acb, y::Float64) |
==(x::Float64, y::acb) |
Examples
CC = ComplexField(64)
x = CC("1 +/- 0.001")
y = CC("3")
z = CC("4")
isequal(x, deepcopy(x))
x == 3
ZZ(3) == z
x != 1.23
Absolute value
Base.abs
— Method.abs(x::acb)
Return the complex absolute value of $x$.
Examples
CC = ComplexField(64)
x = CC("-1 +/- 0.001")
a = abs(x)
Shifting
Base.Math.ldexp
— Method.ldexp(x::acb, y::Int)
Return $2^yx$. Note that $y$ can be positive, zero or negative.
Base.Math.ldexp
— Method.ldexp(x::acb, y::fmpz)
Return $2^yx$. Note that $y$ can be positive, zero or negative.
Examples
CC = ComplexField(64)
x = CC("-3 +/- 0.001")
a = ldexp(x, 23)
b = ldexp(x, -ZZ(15))
Miscellaneous operations
Nemo.trim
— Method.trim(x::acb)
Return an
acb
box containing $x$ but which may be more economical, by rounding off insignificant bits from midpoints.
Nemo.unique_integer
— Method.unique_integer(x::acb)
Return a pair where the first value is a boolean and the second is an
fmpz
integer. The boolean indicates whether the box $x$ contains a unique integer. If this is the case, the second return value is set to this unique integer.
Base.conj
— Method.conj(x::acb)
Return the complex conjugate of $x$.
Base.angle
— Method.angle(x::acb)
Return the angle in radians that the complex vector $x$ makes with the positive real axis in a counterclockwise direction.
Examples
CC = ComplexField(64)
x = CC("-3 +/- 0.001", "0.1")
a = trim(x)
b, c = unique_integer(x)
d = conj(x)
f = angle(x)
Constants
Nemo.const_pi
— Method.const_pi(r::AcbField)
Return $\pi = 3.14159\ldots$ as an element of $r$.
Examples
CC = ComplexField(200)
a = const_pi(CC)
Mathematical and special functions
Base.sqrt
— Method.Base.sqrt(x::acb)
Return the square root of $x$.
Nemo.rsqrt
— Method.rsqrt(x::acb)
Return the reciprocal of the square root of $x$, i.e. $1/\sqrt{x}$.
Base.log
— Method.log(x::acb)
Return the principal branch of the logarithm of $x$.
Base.log1p
— Method.log1p(x::acb)
Return $\log(1+x)$, evaluated accurately for small $x$.
Base.exp
— Method.exp(x::acb)
Return the exponential of $x$.
Nemo.exppii
— Method.exppii(x::acb)
Return the exponential of $\pi i x$.
Base.sin
— Method.sin(x::acb)
Return the sine of $x$.
Base.cos
— Method.cos(x::acb)
Return the cosine of $x$.
Base.Math.sinpi
— Method.sinpi(x::acb)
Return the sine of $\pi x$.
Base.Math.cospi
— Method.cospi(x::acb)
Return the cosine of $\pi x$.
Base.tan
— Method.tan(x::acb)
Return the tangent of $x$.
Base.Math.cot
— Method.cot(x::acb)
Return the cotangent of $x$.
Nemo.tanpi
— Method.tanpi(x::acb)
Return the tangent of $\pi x$.
Nemo.cotpi
— Method.cotpi(x::acb)
Return the cotangent of $\pi x$.
Base.sinh
— Method.sinh(x::acb)
Return the hyperbolic sine of $x$.
Base.cosh
— Method.cosh(x::acb)
Return the hyperbolic cosine of $x$.
Base.tanh
— Method.tanh(x::acb)
Return the hyperbolic tangent of $x$.
Base.Math.coth
— Method.coth(x::acb)
Return the hyperbolic cotangent of $x$.
Base.atan
— Method.atan(x::acb)
Return the arctangent of $x$.
Nemo.logsinpi
— Method.logsinpi(x::acb)
Return $\log\sin(\pi x)$, constructed without branch cuts off the real line.
Nemo.gamma
— Method.gamma(x::acb)
Return the Gamma function evaluated at $x$.
Nemo.lgamma
— Method.lgamma(x::acb)
Return the logarithm of the Gamma function evaluated at $x$.
Nemo.rgamma
— Method.rgamma(x::acb)
Return the reciprocal of the Gamma function evaluated at $x$.
Nemo.digamma
— Method.digamma(x::acb)
Return the logarithmic derivative of the gamma function evaluated at $x$, i.e. $\psi(x)$.
Nemo.zeta
— Method.zeta(x::acb)
Return the Riemann zeta function evaluated at $x$.
Nemo.barnesg
— Method.barnesg(x::acb)
Return the Barnes $G$-function, evaluated at $x$.
Nemo.logbarnesg
— Method.logbarnesg(x::acb)
Return the logarithm of the Barnes $G$-function, evaluated at $x$.
Nemo.erf
— Method.erf(x::acb)
Return the error function evaluated at $x$.
Nemo.erfi
— Method.erfi(x::acb)
Return the imaginary error function evaluated at $x$.
Nemo.ei
— Method.ei(x::acb)
Return the exponential integral evaluated at $x$.
Nemo.si
— Method.si(x::acb)
Return the sine integral evaluated at $x$.
Nemo.ci
— Method.ci(x::acb)
Return the exponential cosine integral evaluated at $x$.
Nemo.shi
— Method.shi(x::acb)
Return the hyperbolic sine integral evaluated at $x$.
Nemo.chi
— Method.chi(x::acb)
Return the hyperbolic cosine integral evaluated at $x$.
Nemo.modeta
— Method.modeta(x::acb)
Return the Dedekind eta function $\eta(\tau)$ at $\tau = x$.
Nemo.modweber_f
— Method.modweber_f(x::acb)
Return the modular Weber function $\mathfrak{f}(\tau) = \frac{\eta^2(\tau)}{\eta(\tau/2)\eta(2\tau)},$ at $x$ in the complex upper half plane.
Nemo.modweber_f1
— Method.modweber_f1(x::acb)
Return the modular Weber function $\mathfrak{f}_1(\tau) = \frac{\eta(\tau/2)}{\eta(\tau)},$ at $x$ in the complex upper half plane.
Nemo.modweber_f2
— Method.modweber_f2(x::acb)
Return the modular Weber function $\mathfrak{f}_2(\tau) = \frac{\sqrt{2}\eta(2\tau)}{\eta(\tau)}$ at $x$ in the complex upper half plane.
Nemo.modj
— Method.modj(x::acb)
Return the $j$-invariant $j(\tau)$ at $\tau = x$.
Nemo.modlambda
— Method.modlambda(x::acb)
Return the modular lambda function $\lambda(\tau)$ at $\tau = x$.
Nemo.moddelta
— Method.moddelta(x::acb)
Return the modular delta function $\Delta(\tau)$ at $\tau = x$.
Nemo.ellipk
— Method.ellipk(x::acb)
Return the complete elliptic integral $K(x)$.
Nemo.ellipe
— Method.ellipe(x::acb)
Return the complete elliptic integral $E(x)$.
Base.Math.sincos
— Method.sincos(x::acb)
Return a tuple $s, c$ consisting of the sine $s$ and cosine $c$ of $x$.
Nemo.sincospi
— Method.sincospi(x::acb)
Return a tuple $s, c$ consisting of the sine $s$ and cosine $c$ of $\pi x$.
Nemo.sinhcosh
— Method.sinhcosh(x::acb)
Return a tuple $s, c$ consisting of the hyperbolic sine and cosine of $x$.
Nemo.agm
— Method.agm(x::acb)
Return the arithmetic-geometric mean of $1$ and $x$.
Nemo.agm
— Method.agm(x::acb, y::acb)
Return the arithmetic-geometric mean of $x$ and $y$.
Nemo.polygamma
— Method.polygamma(s::acb, a::acb)
Return the generalised polygamma function $\psi(s,z)$.
Nemo.zeta
— Method.zeta(s::acb, a::acb)
Return the Hurwitz zeta function $\zeta(s,a)$.
Nemo.risingfac
— Method.risingfac(x::acb, n::Int)
Return the rising factorial $x(x + 1)\ldots (x + n - 1)$ as an Acb.
Nemo.risingfac2
— Method.risingfac2(x::acb, n::Int)
Return a tuple containing the rising factorial $x(x + 1)\ldots (x + n - 1)$ and its derivative.
Nemo.polylog
— Method.polylog(s::acb, a::acb)
Nemo.polylog
— Method.polylog(s::Int, a::acb)
Return the polylogarithm Li$_s(a)$.
Nemo.li
— Method.li(x::acb)
Return the logarithmic integral, evaluated at $x$.
Nemo.lioffset
— Method.lioffset(x::acb)
Return the offset logarithmic integral, evaluated at $x$.
Nemo.expint
— Method.expint(s::acb, x::acb)
Return the generalised exponential integral $E_s(x)$.
Nemo.gamma
— Method.gamma(s::acb, x::acb)
Return the upper incomplete gamma function $\Gamma(s,x)$.
Nemo.besselj
— Method.besselj(nu::acb, x::acb)
Return the Bessel function $J_{\nu}(x)$.
Nemo.bessely
— Method.bessely(nu::acb, x::acb)
Return the Bessel function $Y_{\nu}(x)$.
Nemo.besseli
— Method.besseli(nu::acb, x::acb)
Return the Bessel function $I_{\nu}(x)$.
Nemo.besselk
— Method.besselk(nu::acb, x::acb)
Return the Bessel function $K_{\nu}(x)$.
Nemo.hyp1f1
— Method.hyp1f1(a::acb, b::acb, x::acb)
Return the confluent hypergeometric function ${}_1F1(a,b,x)$.
Nemo.hyp1f1r
— Method.hyp1f1r(a::acb, b::acb, x::acb)
Return the regularized confluent hypergeometric function ${}_1F1(a,b,x) / \Gamma(b)$.
Nemo.hyperu
— Method.hyperu(a::acb, b::acb, x::acb)
Return the confluent hypergeometric function $U(a,b,x)$.
Nemo.hyp2f1
— Method.hyp2f1(a::acb, b::acb, c::acb, x::acb; flags=0)
Return the Gauss hypergeometric function ${}_2F_1(a,b,c,x)$.
Nemo.jtheta
— Method.jtheta(z::acb, tau::acb)
Return a tuple of four elements containing the Jacobi theta function values $\theta_1, \theta_2, \theta_3, \theta_4$ evaluated at $z, \tau$.
Nemo.ellipwp
— Method.ellipwp(z::acb, tau::acb)
Return the Weierstrass elliptic function $\wp(z,\tau)$.
Examples
CC = ComplexField(64)
s = CC(1, 2)
z = CC("1.23", "3.45")
a = sin(z)^2 + cos(z)^2
b = zeta(z)
c = besselj(s, z)
d = hyp1f1(s, s+1, z)
Linear dependence
Nemo.lindep
— Method.lindep(A::Array{acb, 1}, bits::Int)
Find a small linear combination of the entries of the array $A$ that is small (using LLL). The entries are first scaled by the given number of bits before truncating the real and imaginary parts to integers for use in LLL. This function can be used to find linear dependence between a list of complex numbers. The algorithm is heuristic only and returns an array of Nemo integers representing the linear combination.
Nemo.lindep
— Method.lindep(A::Array{acb, 2}, bits::Int)
Find a (common) small linear combination of the entries in each row of the array $A$, that is small (using LLL). It is assumed that the complex numbers in each row of the array share the same linear combination. The entries are first scaled by the given number of bits before truncating the real and imaginary parts to integers for use in LLL. This function can be used to find a common linear dependence shared across a number of lists of complex numbers. The algorithm is heuristic only and returns an array of Nemo integers representing the common linear combination.
Examples
CC = ComplexField(128)
# These are two of the roots of x^5 + 3x + 1
a = CC(1.0050669478588622428791051888364775253, - 0.93725915669289182697903585868761513585)
b = CC(-0.33198902958450931620250069492231652319)
# We recover the polynomial from one root....
V1 = [CC(1), a, a^2, a^3, a^4, a^5];
W = lindep(V1, 20)
# ...or from two
V2 = [CC(1), b, b^2, b^3, b^4, b^5];
Vs = [V1 V2]'
X = lindep(Vs, 20)