def test_cosh4(): # AD object with .val=[1,2] x1 = AD(val=[1, 2], index=0, magnitude=2) # AD object with .val=[2,3] x2 = AD(val=[2, 3], index=1, magnitude=2) y = ef.cosh(x1 + x2) assert y.val == pytest.approx(np.cosh([3, 5])) assert y.der[0] == pytest.approx(np.sinh([3, 5]) * 1) assert y.der[1] == pytest.approx(np.sinh([3, 5]) * 1)
def test_cosh1(): # default AD object with .val=[0.0] x = AD() y = ef.cosh(x) assert y.val == pytest.approx(np.cosh(0)) assert y.der == pytest.approx(np.sinh(0) * 1)
def test_cosh2(): # AD object with .val=[1,2] x = AD(val=[1, 2], index=0, magnitude=1) y = ef.cosh(x) assert y.val == pytest.approx(np.cosh([1, 2])) assert y.der[0] == pytest.approx(np.sinh([1, 2]) * 1)
def test_cosh0(): x = 1 assert ef.cosh(x) == pytest.approx(np.cosh(x))