mirror of
https://github.com/vale981/arb
synced 2025-03-05 09:21:38 -05:00
return exact zero where possible: acos, acosh
This commit is contained in:
parent
1288a174e3
commit
1bd2179a46
2 changed files with 38 additions and 3 deletions
26
acb/acos.c
26
acb/acos.c
|
@ -23,9 +23,29 @@ acb_acos(acb_t res, const acb_t z, slong prec)
|
|||
acb_t t;
|
||||
acb_init(t);
|
||||
acb_asin(res, z, prec);
|
||||
acb_const_pi(t, prec);
|
||||
acb_mul_2exp_si(t, t, -1);
|
||||
acb_sub(res, t, res, prec);
|
||||
if (arb_is_zero(acb_imagref(z)))
|
||||
{
|
||||
arb_t one;
|
||||
arb_init(one);
|
||||
arb_one(one);
|
||||
if (arb_gt(acb_realref(z), one))
|
||||
{
|
||||
arb_zero(acb_realref(res));
|
||||
}
|
||||
else
|
||||
{
|
||||
acb_const_pi(t, prec);
|
||||
acb_mul_2exp_si(t, t, -1);
|
||||
acb_sub(res, t, res, prec);
|
||||
}
|
||||
arb_clear(one);
|
||||
}
|
||||
else
|
||||
{
|
||||
acb_const_pi(t, prec);
|
||||
acb_mul_2exp_si(t, t, -1);
|
||||
acb_sub(res, t, res, prec);
|
||||
}
|
||||
acb_clear(t);
|
||||
}
|
||||
}
|
||||
|
|
15
acb/acosh.c
15
acb/acosh.c
|
@ -32,6 +32,21 @@ acb_acosh(acb_t res, const acb_t z, slong prec)
|
|||
acb_add(t, t, z, prec);
|
||||
acb_log(res, t, prec);
|
||||
|
||||
if (arb_is_zero(acb_imagref(z)))
|
||||
{
|
||||
arb_t one, abs;
|
||||
arb_init(one);
|
||||
arb_init(abs);
|
||||
arb_one(one);
|
||||
arb_abs(abs, acb_realref(z));
|
||||
if (arb_lt(abs, one))
|
||||
{
|
||||
arb_zero(acb_realref(res));
|
||||
}
|
||||
arb_clear(one);
|
||||
arb_clear(abs);
|
||||
}
|
||||
|
||||
acb_clear(t);
|
||||
acb_clear(u);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue