Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrik-johansson committed Dec 30, 2024
1 parent 39d48fe commit 74014f1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
21 changes: 20 additions & 1 deletion examples/integrals.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,11 +732,22 @@ scaled_bessel_select_N(arb_t N, ulong k, slong prec)
arb_mul_2exp_si(N, N, e);
}

/* f(z) = Si(z) */
int
f_si(acb_ptr res, const acb_t z, void * param, slong order, slong prec)
{
if (order > 1)
flint_abort(); /* Would be needed for Taylor method. */

acb_hypgeom_si(res, z, prec);
return 0;
}

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

#define NUM_INTEGRALS 37
#define NUM_INTEGRALS 38

const char * descr[NUM_INTEGRALS] =
{
Expand Down Expand Up @@ -777,6 +788,7 @@ const char * descr[NUM_INTEGRALS] =
"int_0^{inf} exp(-x) I_0(x/15)^{15} dx (using domain truncation)",
"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 main(int argc, char *argv[])
Expand Down Expand Up @@ -1273,6 +1285,13 @@ int main(int argc, char *argv[])
arb_add_error_2exp_si(acb_realref(s), -goal);
break;

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


default:
abort();
}
Expand Down
1 change: 1 addition & 0 deletions src/acb_hypgeom/chi.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ acb_hypgeom_chi(acb_t res, const acb_t z, slong prec)
wp = prec + FLINT_MAX(0, cancellation);
wp = wp * 1.001 + 5;
acb_hypgeom_chi_2f3(res, m, wp);
acb_set_round(res, res, prec);
}

if (pure_real)
Expand Down
1 change: 1 addition & 0 deletions src/acb_hypgeom/ci.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ acb_hypgeom_ci(acb_t res, const acb_t z, slong prec)
wp = prec + FLINT_MAX(0, cancellation);
wp = wp * 1.001 + 5;
acb_hypgeom_ci_2f3(res, m, wp);
acb_set_round(res, res, prec);
}

acb_add_error_mag(res, err);
Expand Down
1 change: 1 addition & 0 deletions src/acb_hypgeom/ei.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ acb_hypgeom_ei(acb_t res, const acb_t z, slong prec)
wp = prec + FLINT_MAX(0, cancellation);
wp = wp * 1.001 + 5;
acb_hypgeom_ei_2f2(res, m, wp);
acb_set_round(res, res, prec);
}

if (pure_real)
Expand Down
1 change: 1 addition & 0 deletions src/acb_hypgeom/si.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ acb_hypgeom_si(acb_t res, const acb_t z, slong prec)
wp = prec + FLINT_MAX(0, cancellation);
wp = wp * 1.001 + 5;
acb_hypgeom_si_1f2(res, m, wp);
acb_set_round(res, res, prec);
}

if (pure_imag)
Expand Down
12 changes: 8 additions & 4 deletions src/python/flint_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1913,14 +1913,18 @@ def exp_integral(ctx, x, y):
def exp_integral_ei(ctx, x):
"""
>>> RR.exp_integral_ei(1)
[1.89511781635594 +/- 5.11e-15]
[1.895117816355937 +/- 6.91e-16]
"""
return ctx._unary_op(x, libgr.gr_exp_integral_ei, "exp_integral_ei($x)")

def sin_integral(ctx, x):
"""
>>> RR.sin_integral(1)
[0.946083070367183 +/- 1.35e-16]
>>> CC.sin_integral(CC("(5 +/- 1e-10)*I"))
[20.09321183 +/- 5.79e-9]*I
>>> CC.sin_integral(CC("10 + (1 +/- 1e-10)*I"))
([1.7002629761 +/- 6.33e-11] + [-0.0667638998 +/- 2.17e-11]*I)
"""
return ctx._unary_op(x, libgr.gr_sin_integral, "sin_integral($x)")

Expand All @@ -1934,21 +1938,21 @@ def cos_integral(ctx, x):
def sinh_integral(ctx, x):
"""
>>> RR.sinh_integral(1)
[1.05725087537573 +/- 2.77e-15]
[1.057250875375728 +/- 6.29e-16]
"""
return ctx._unary_op(x, libgr.gr_sinh_integral, "sinh_integral($x)")

def cosh_integral(ctx, x):
"""
>>> RR.cosh_integral(1)
[0.837866940980208 +/- 4.78e-16]
[0.837866940980208 +/- 3.15e-16]
"""
return ctx._unary_op(x, libgr.gr_cosh_integral, "cosh_integral($x)")

def log_integral(ctx, x, offset=False):
"""
>>> RR.log_integral(2)
[1.04516378011749 +/- 4.01e-15]
[1.04516378011749 +/- 3.31e-15]
>>> RR.log_integral(2, offset=True)
0
"""
Expand Down

0 comments on commit 74014f1

Please sign in to comment.