add mag_const_pi and improve the worst-case bound in arb_atan

This commit is contained in:
Fredrik Johansson 2016-03-02 13:41:47 +01:00
parent ce58576143
commit 35c7c9b27b
3 changed files with 15 additions and 0 deletions

View file

@ -334,6 +334,12 @@ arb_atan(arb_t z, const arb_t x, slong prec)
mag_div(t, arb_radref(x), t);
}
if (mag_cmp_2exp_si(t, 0) > 0)
{
mag_const_pi(u);
mag_min(t, t, u);
}
arb_atan_arf(z, arb_midref(x), prec);
mag_add(arb_radref(z), arb_radref(z), t);

View file

@ -334,6 +334,10 @@ Powers and logarithms
Special functions
-------------------------------------------------------------------------------
.. function:: void mag_const_pi(mag_t z)
Sets *z* to an upper bound for `\pi`.
.. function:: void mag_fac_ui(mag_t z, ulong n)
Sets *z* to an upper bound for `n!`.

5
mag.h
View file

@ -697,6 +697,11 @@ mag_div_fmpz(mag_t z, const mag_t x, const fmpz_t y)
mag_clear(t);
}
MAG_INLINE void mag_const_pi(mag_t res)
{
mag_set_ui_2exp_si(res, 843314857, -28);
}
#ifdef __cplusplus
}
#endif