arb_get_bits returning a few bits less than what arb_set_str was called with

28 views
Skip to first unread message

Stephen Crowley

unread,
Mar 27, 2024, 6:27:32 PMMar 27
to flint-devel
Subject: Inquiry on `` Behavior with Specified Precision


When initializing an `arb_t` variable with `arb_set_str("3.37", 128)`, the subsequent invocation of `arb_get_bits` behaves as expected, reflecting the initialized precision. However, initializing with a different value, such as `arb_set_str("3.7", 128)`, results in `arb_get_bits` indicating a precision of 126 bits instead of the specified 128. What determines the effective precision reported by `arb_get_bits`, and how can one predict or control this variance in precision for different values?

Thanks in advance

--Stephen

p.s. a new milestone for arb4j was achieved

public static void testSum()

{

try ( HypergeometricPolynomial F = new HypergeometricPolynomial(2,

1))

{

F.α.set(-6, 2.5);

F.β.set(1);

RealPolynomial polynomial = F.evaluate(null, 128, new RealPolynomial());

assertEquals("1 - 15x + 65.625x² - 131.25x³ + 135.3515625x⁴ - 70.3828125x⁵ + 14.6630859375x⁶",

polynomial.toString());

double val = polynomial.eval(2.3);

assertEquals(145.01289685058583, val);

}

}


and the HypergeometricPolynomial itself is mostly just management for the

variables and main implementation is generated dynamically by the expression compiler


public HypergeometricPolynomial(int p, int q)

{

context = new Context(this.p = new Integer(p,"p"),

this.q = new Integer(q,"q"),

α = Real.newVector(p).setName("α"),

β = Real.newVector(q).setName("β"));

context.registerVariable("N", N = new Integer());


F =

RealPolynomialNullaryFunction.express("F",

"Σn➔zⁿ*∏k➔α[k]₍ₙ₎{k=1…p}/(n!*∏k➔β[k]₍ₙ₎{k=1…q}){n=0…N}",

context);

}




Fredrik Johansson

unread,
Mar 27, 2024, 6:49:08 PMMar 27
to flint...@googlegroups.com
Hi Stephen,

arb_bits() returns the bit length of the mantissa. For a result computed at prec bits of precision this can be anywhere in the range 0 <= b <= prec. For example 0 has 0 bits, 0.25 has 2 bits, and 3.7 has 126 bits after rounding to prec = 128 (with the default rounding mode) because the two least significant bits are zero and thus get discarded.

The number of bits can thus be arbitrarily smaller than the precision, and need not be related to the accuracy at all.

Note that arb_t variables have no memory of what precisions have been used in previous operations. arb_bits() effectively just gives a lower bound. If you want to track the used working precision, you need to do it yourself, e.g. storing an extra precision field next to your arb_t.

Fredrik

--

---
You received this message because you are subscribed to the Google Groups "flint-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flint-devel...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/flint-devel/2912741a-b1ec-4e6b-9ecc-252efa9d2118n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages