def test_tanh_sinh(f, a, b, exact):
# test fine error estimate
mp.dps = 50
tol = 10**(-mp.dps)
tol2 = 10**(-mp.dps+1)
t = sympy.Symbol('t')
f_derivatives = {
1: sympy.lambdify(t, sympy.diff(f(t), t, 1), modules=['mpmath']),
2: sympy.lambdify(t, sympy.diff(f(t), t, 2), modules=['mpmath']),
}
value, _ = quadpy.line_segment.tanh_sinh(
f, a, b, tol,
f_derivatives=f_derivatives
)
assert abs(value - exact) < tol2
# test with crude estimate
value, _ = quadpy.line_segment.tanh_sinh(f, a, b, tol)
assert abs(value - exact) < tol2
return
# Test functions with singularities at both ends.
评论列表
文章目录