def test_2xe2x(): x = ADnum(2, der=1) f = 2 * x * ADmath.exp(2 * x) assert f.val == 4 * np.exp(4) assert f.der == 2 * np.exp(4.0) + 8 * np.exp(4)
def test_ADmath_expr(): f = ADmath.exp(-3) assert f == np.exp(-3)
def test_xex(): x = ADnum(2, der=1) f = x * ADmath.exp(x) assert f.val == 2.0 * np.exp(2.0) assert f.der == np.exp(2.0) + 2.0 * np.exp(2.0)
def test_ADmath_exp(): f = ADmath.exp(ADnum(-3, der=1)) assert f.val == np.exp(-3) assert f.der == np.exp(-3) assert len(f.graph) == 1