def test_7(): ''' Testing x**2/sqrt(x) + arccos(x) derivative and value This also tests division and power overrides ''' v = 4 x = AD.AADVariable(v) x = x**2 / AD.sqrt(x) #value check assert abs(x.val - v**2 / math.sqrt(v)) < tol #derivative check assert abs(x.der - (3. * math.sqrt(v)) / 2.) < tol
def test_6(): ''' Testing sqrt(x)*arctan(x) + arccos(x) derivative and value This also tests multiplication operator overides ''' v = 0.5 x = AD.AADVariable((v)) x = AD.sqrt(x) * AD.arctan(x) + AD.arccos(x) #value check assert abs(x.val - (math.sqrt(v) * math.atan(v) + math.acos(v))) < tol #derivative check assert abs(x.der - (math.sqrt(v) / (v**2 + 1.) - 1. / (math.sqrt(1. - v**2)) + (math.atan(v) / (2. * math.sqrt(v))))) < tol