Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
def rm_test_sin():
    Test_Dual_Number_1 = DualNumber(1,Reverse=True)
    assert EF.Sin(Test_Dual_Number_1).val == np.sin(1) and EF.Sin(Test_Dual_Number_1).der == 0
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
def test_sinh():
    Test_Dual_Number_1 = DualNumber(1)
    assert EF.Sinh(Test_Dual_Number_1).val == np.sinh(1) and EF.Sinh(Test_Dual_Number_1).der == np.cosh(1)
    Test_Dual_Number_1 = 1
    assert EF.Sinh(Test_Dual_Number_1).val == np.sinh(1) and EF.Sin(Test_Dual_Number_1).der == 0