test_interface.py 文件源码

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

项目:zippy 作者: securesystemslab 项目源码 文件源码
def test_function_series3():
    """
    Test our easy "tanh" function.

    This test tests two things:
      * that the Function interface works as expected and it's easy to use
      * that the general algorithm for the series expansion works even when the
        derivative is defined recursively in terms of the original function,
        since tanh(x).diff(x) == 1-tanh(x)**2
    """

    class mytanh(Function):

        def fdiff(self, argindex=1):
            return 1 - mytanh(self.args[0])**2

        @classmethod
        def eval(cls, arg):
            arg = sympify(arg)
            if arg == 0:
                return sympify(0)

    e = tanh(x)
    f = mytanh(x)
    assert tanh(x).series(x, 0, 6) == mytanh(x).series(x, 0, 6)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号