# Ball methods

The following methods are useful for explicitly dealing with the ball representation of Arb and related values.

## Construction

For constructing balls the methods below are useful. Note that there is no setinterval method, this is instead accomplished with Arb((a, b)) for constructing a ball containing the interval $[a, b]$.

Arblib.setballFunction
setball(::Type{Arb}, m, r; prec = _precision(m))

Returns an Arb with the midpoint and radius set to m and r respectively.

Note that the m is converted to an Arf and therefore rounded. So for example setball(1 // 3, 0) will not contain $1 / 3$.

See also getball and add_error.

Arblib.add_errorFunction
add_error(x, err)

Returns a copy of x with the absolute value of err added to the radius.

For complex x it adds the error to both the real and imaginary parts. For matrices it adds it elementwise.

See also setball.

## Destruction

For extracting information about the ball representation the following methods are useful.

Arblib.radiusFunction
radius([T, ] x::ArbOrRef)

Returns the radius of x as a Mag. If T is given convert to this type, supports Mag, Arf, Arb and Float64.

Arblib.midpointFunction
midpoint([T, ] x::ArbOrRef)

Returns the midpoint of x as an Arf. If T is given convert to this type, supports Arf and Arb.

midpoint([T, ] z::AcbOrRef)

Returns the midpoint of z as a Complex{Arf}. If T is given and equal to Arf or Arb, convert to Complex{T}. If T is Acb then convert to that.

Arblib.lboundFunction
lbound([T, ] x::ArbOrRef)

Returns a lower bound of x as an Arf. If T is given convert to this type, supports Arf and Arb.

If x contains NaN it returns NaN.

Arblib.uboundFunction
ubound([T, ] x::ArbOrRef)

Returns an upper bound of x as an Arf. If T is given convert to this type, supports Arf and Arb.

If x contains NaN it returns NaN.

Arblib.abs_lboundFunction
abs_lbound([T, ] x::Union{ArbOrRef,AcbOrRef})

Returns a lower bound of abs(x) as an Arf. If T is given convert to this type, supports Arf and Arb.

If x contains NaN it returns NaN.

Arblib.abs_uboundFunction
abs_ubound([T, ] x::Union{ArbOrRef,AcbOrRef})

Returns an upper bound of abs(x) as an Arf. If T is given convert to this type, supports Arf and Arb.

If x contains NaN it returns NaN.

Arblib.getintervalFunction
getinterval([T, ] x::ArbOrRef)

Returns a tuple (l, u) representing an interval [l, u] enclosing the ball x, both of them are of type Arf. If T is given convert to this type, supports Arf, BigFloat and Arb.

If x contains NaN both l and u will be NaN.

See also getball.

Arblib.getballFunction
getball([T, ] x::ArbOrRef)

Returns a tuple (m::Arf, r::Mag) where m is the midpoint of the ball and r is the radius. If T is given convert both m and r to this type, supports Arf and Arb.

See also setball and getinterval.

## Union and intersection

The methods Arblib.union and Arblib.intersection compute the union and intersection of balls. Note that these methods are not exported and different from Base.union and Base.intersect.

Arblib.unionFunction
union(x::ArbOrRef, y::ArbOrRef)
union(x::AcbOrRef, y::AcbOrRef)
union(x::T, y::T) where {T<:Union{ArbPoly,AcbPoly,ArbSeries,AcbSeries}}
union(x, y, z...)

Returns a ball containing the union of x and y. For polynomials and series the union is taken coefficient-wise.

union(x, y, z...) returns a ball containing the union of all given balls.

Arblib.intersectionFunction
intersection(x::ArbOrRef, y::ArbOrRef)
intersection(x::T, y::T) where {T<:Union{ArbPoly,ArbSeries}}
intersection(x, y, z...)

intersection(x, y) returns a ball containing the intersection of x and y. If x and y do not overlap (as given by overlaps(a, b)) throws an ArgumentError. For polynomials and series the intersection is taken coefficient-wise.

intersection(x, y, z...) returns a ball containing the intersection of all given balls. If all the balls do not overlap throws an ArgumentError.