Skip to content

Commit

Permalink
closes sympy#15498
Browse files Browse the repository at this point in the history
  • Loading branch information
smichr committed Mar 16, 2024
1 parent 83ca9d9 commit ca87484
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion sympy/integrals/tests/test_heurisch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from sympy.core.add import Add
from sympy.core.function import (Derivative, Function, diff)
from sympy.core.numbers import (I, Rational, pi)
from sympy.core.relational import Ne
from sympy.core.relational import Eq, Ne
from sympy.core.symbol import (Symbol, symbols)
from sympy.functions.elementary.exponential import (LambertW, exp, log)
from sympy.functions.elementary.hyperbolic import (asinh, cosh, sinh, tanh)
Expand All @@ -12,6 +12,8 @@
from sympy.functions.special.bessel import (besselj, besselk, bessely, jn)
from sympy.functions.special.error_functions import erf
from sympy.integrals.integrals import Integral
from sympy.logic.boolalg import And
from sympy.matrices import Matrix
from sympy.simplify.ratsimp import ratsimp
from sympy.simplify.simplify import simplify
from sympy.integrals.heurisch import components, heurisch, heurisch_wrapper
Expand Down Expand Up @@ -378,3 +380,20 @@ def test_heurisch_complex_erf_issue_26338():
assert heurisch(a, x, hints=[]) is None # None, not a wrong soln
a = sqrt(pi)*erf((1 + I)/2)/2
assert integrate(exp(-I*x**2/2), (x, 0, 1)) == a - I*a


def test_issue_15498():
Z0 = Function('Z0')
k01, k10, t, s= symbols('k01 k10 t s', real=True, positive=True)
m = Matrix([[exp(-k10*t)]])
_83 = Rational(83, 100) # 0.83 works, too
[a, b, c, d, e, f, g] = [100, 0.5, _83, 50, 0.6, 2, 120]
AIF_btf = a*(d*e*(1 - exp(-(t - b)/e)) + f*g*(1 - exp(-(t - b)/g)))
AIF_atf = a*(d*e*exp(-(t - b)/e)*(exp((c - b)/e) - 1
) + f*g*exp(-(t - b)/g)*(exp((c - b)/g) - 1))
AIF_sym = Piecewise((0, t < b), (AIF_btf, And(b <= t, t < c)), (AIF_atf, c <= t))
aif_eq = Eq(Z0(t), AIF_sym)
f_vec = Matrix([[k01*Z0(t)]])
integrand = m*m.subs(t, s)**-1*f_vec.subs(aif_eq.lhs, aif_eq.rhs).subs(t, s)
solution = integrate(integrand[0], (s, 0, t))
assert solution is not None # does not hang and takes less than 10 s

0 comments on commit ca87484

Please sign in to comment.