def test_1(): ''' Testing sin(x) derivative and value ''' x = AD.AADVariable((math.pi / 2)) x = AD.sin(x) #value check assert abs(x.val - math.sin(math.pi / 2)) < tol #derivative check assert abs(x.der - math.cos(math.pi / 2)) < tol
def test_2(): ''' Testing sin(cos(x)) derivative and value ''' x = AD.AADVariable((math.pi)) x = AD.sin(AD.cos(x)) #value check assert abs(x.val - math.sin(math.cos(math.pi))) < tol #derivative check assert abs(x.der - (-math.cos(math.cos(math.pi)) * math.sin(math.pi))) < tol