def Given_function(x): x = DualNumber(x) y = EF.Sin(x) * EF.Cos(x) * EF.Tan(x) - EF.Exp(x) * EF.Log(x) * EF.Sqrt( x) * 2 return y #y=sin(x)cos(x)tan(x)-2exp(x)log(x)sqrt(x)
def Demo_gradient(x): x=DualNumber(x); y=-EF.Sin(x)*EF.Cos(x)*EF.Tan(x)+EF.Exp(x)*EF.Log(x)*EF.Sqrt(x)*2 return y.der #y=sin(x)cos(x)tan(x)-2exp(x)log(x)sqrt(x)
def rm_test_tan(): Test_Dual_Number_1 = DualNumber(1,Reverse=True) assert EF.Tan(Test_Dual_Number_1).val == np.tan(1) and EF.Tan(Test_Dual_Number_1).der == 0