def test_tangent_gradient(self): cg = CGraph() x = Function(1.) y1 = algopy.tan(x) cg.trace_off() cg.independentFunctionList = [x] cg.dependentFunctionList = [y1] g1 = cg.gradient([1.])[0] x = UTPM.init_jacobian(1.) assert_array_almost_equal(g1,UTPM.extract_jacobian(algopy.sin(x)/algopy.cos(x))) assert_array_almost_equal(g1,UTPM.extract_jacobian(algopy.tan(x)))
def eval_f2(x): y = algopy.zeros(3, dtype=x) y[0] = x[1] + x[2] - 5. y[1] = -1./x[0] + x[2]**3 + 1. y[2] = -x[1] + algopy.tan(x[0]) -x[2] + 7. return y