test_tanh_sinh.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:quadpy 作者: nschloe 项目源码 文件源码
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.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号