def repr_test(): ''' Tests __repr__ of AD object ''' x = AD.AADVariable((math.pi)) x = 2**AD.exp(x) repr(x)
def jacobian_test(): ''' Tests formation of jacobian ''' x = AD.AADVariable((math.pi)) x = 2**AD.exp(x) assert abs(x.jacobian() - 2**(math.exp(math.pi)) * math.exp(math.pi) * math.log(2)) < tol
def test_3(): ''' Testing exp(tan(x)) derivative and value ''' x = AD.AADVariable((math.pi)) x = AD.exp(AD.tan(x)) #value check assert abs(x.val - math.exp(math.tan(math.pi))) < tol #derivative check assert abs(x.der - math.exp(math.tan(math.pi)) * 1 / math.cos(math.pi)**2) < tol
def test_10(): ''' Testing 2^exp(x) derivative and value Testing alternative power symbol ''' x = AD.AADVariable((math.pi)) x = 2**AD.exp(x) #value check assert abs(x.val - 2**math.exp(math.pi)) < tol #derivative check assert abs(x.der - 2**(math.exp(math.pi)) * math.exp(math.pi) * math.log(2)) < tol