Skip to content

Commit

Permalink
Merge pull request flintlib#2137 from fredrik-johansson/bessel
Browse files Browse the repository at this point in the history
Improve bessel_j in transition region
  • Loading branch information
fredrik-johansson authored Jan 7, 2025
2 parents 86a8c10 + 986bb94 commit 151f514
Show file tree
Hide file tree
Showing 7 changed files with 606 additions and 23 deletions.
5 changes: 5 additions & 0 deletions doc/source/acb_hypgeom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ Error functions and Fresnel integrals
Bessel functions
-------------------------------------------------------------------------------

.. function:: void acb_hypgeom_bessel_j_deriv_bound(mag_t res, const acb_t nu, const acb_t z, ulong d)

Sets *res* to a bound, possibly crude, for `|J^{(d)}_{\nu}(z)|`.
Currently only specialized for small integer `\nu` and small `d`.

.. function:: void acb_hypgeom_bessel_j_asymp(acb_t res, const acb_t nu, const acb_t z, slong prec)

Computes the Bessel function of the first kind
Expand Down
30 changes: 29 additions & 1 deletion examples/integrals.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,11 +743,33 @@ f_si(acb_ptr res, const acb_t z, void * param, slong order, slong prec)
return 0;
}

/* f(z) = J_0(z) J_1(z) J_2(z) */
int
f_triple_bessel_j(acb_ptr res, const acb_t z, void * param, slong order, slong prec)
{
acb_t t;

if (order > 1)
flint_abort(); /* Would be needed for Taylor method. */

acb_init(t);
acb_hypgeom_bessel_j(res, t, z, prec);
acb_set_ui(t, 1);
acb_hypgeom_bessel_j(t, t, z, prec);
acb_mul(res, res, t, prec);
acb_set_ui(t, 2);
acb_hypgeom_bessel_j(t, t, z, prec);
acb_mul(res, res, t, prec);
acb_clear(t);

return 0;
}

/* ------------------------------------------------------------------------- */
/* Main test program */
/* ------------------------------------------------------------------------- */

#define NUM_INTEGRALS 38
#define NUM_INTEGRALS 39

const char * descr[NUM_INTEGRALS] =
{
Expand Down Expand Up @@ -789,6 +811,7 @@ const char * descr[NUM_INTEGRALS] =
"int_{-1-i}^{-1+i} 1/sqrt(x) dx",
"int_0^{inf} 1/gamma(x) dx (using domain truncation)",
"int_0^{1000} Si(x) dx",
"int_0^{1000} J_0(x) J_1(x) J_2(x) dx",
};

int main(int argc, char *argv[])
Expand Down Expand Up @@ -1291,6 +1314,11 @@ int main(int argc, char *argv[])
acb_calc_integrate(s, f_si, NULL, a, b, goal, tol, options, prec);
break;

case 38:
acb_zero(a);
acb_set_ui(b, 1000);
acb_calc_integrate(s, f_triple_bessel_j, NULL, a, b, goal, tol, options, prec);
break;

default:
abort();
Expand Down
1 change: 1 addition & 0 deletions src/acb_hypgeom.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ void acb_hypgeom_m_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, i
void acb_hypgeom_m(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec);
void acb_hypgeom_1f1(acb_t res, const acb_t a, const acb_t b, const acb_t z, int regularized, slong prec);

void acb_hypgeom_bessel_j_deriv_bound(mag_t res, const acb_t nu, const acb_t z, ulong d);
void acb_hypgeom_bessel_j_0f1(acb_t res, const acb_t nu, const acb_t z, slong prec);
void acb_hypgeom_bessel_j_asymp(acb_t res, const acb_t nu, const acb_t z, slong prec);
void acb_hypgeom_bessel_j(acb_t res, const acb_t nu, const acb_t z, slong prec);
Expand Down
Loading

0 comments on commit 151f514

Please sign in to comment.