The mag_t type is an unsigned floating-point type with a fixed-precision mantissa (30 bits) and an arbitrary-precision exponent (represented as an fmpz_t), suited for representing and rigorously manipulating magnitude bounds efficiently. Operations always produce a strict upper or lower bound, but for performance reasons, no attempt is made to compute the best possible bound (in general, a result may a few ulps larger/smaller than the optimal value). The special values zero and positive infinity are supported (but not NaN). Applications requiring more flexibility (such as correct rounding, or higher precision) should use the arf_t type instead.
A mag_struct holds a mantissa and an exponent. Special values are encoded by the mantissa being set to zero.
A mag_t is defined as an array of length one of type mag_struct, permitting a mag_t to be passed by reference.
Allocates a vector of length n. All entries are set to zero.
Clears a vector of length n.
Returns nonzero iff x is not positive infinity (since there is no NaN value, this function is exactly the negation of mag_is_inf()).
Returns negative, zero, or positive, depending on whether x is smaller, equal, or larger than y.
Sets x to a random finite value, with an exponent up to expbits bits large.
Like mag_randtest(), but also sometimes sets x to infinity.
Sets z to \(x \times 2^y\). This operation is exact.
Sets z to an upper bound for \(x + 2^e\).
The following methods assume that all inputs are finite and that all exponents (in all inputs as well as the final result) fit as fmpz inline values. They also assume that the output variables do not have promoted exponents, as they will be overwritten directly (thus leaking memory).
Sets z to an upper bound for \(z + xy\).
Sets z to an upper bound for \(x^e\). Requires \(e \ge 0\).
Sets z to an upper bound for \(\sqrt{x^2 + y^2}\).
Sets z to an upper bound for \(\log(1+x)\). The bound is computed accurately for small x.
Sets z to an upper bound for \(\exp(x) - 1\). The bound is computed accurately for small x.
Sets z to an upper bound for \(|B_n| / n!\) where \(B_n\) denotes a Bernoulli number.
Sets u to an upper bound for
Note: in applications where \(s\) in this formula may be real or complex, the user can simply substitute any convenient integer \(s'\) such that \(s' \le \operatorname{Re}(s)\).
Denote the terms by \(T(k)\). We pick a nonincreasing function \(U(k)\) such that
Then, as soon as \(U(N) < 1\),
In particular, we take
where \(B(m,n) = (1 + 1/m)^n\). This follows from the bounds
and