def test_csch_s(s): def value(x): return 1 / math.sinh(x) output = ad.csch(s) assert output.value == pytest.approx(value(s)) assert output.derivatives == {}
def test_csch_sm(m): def value(x): return 1 / math.sinh(x) output = ad.csch(m) for i in range(len(m)): assert output.value[i] == pytest.approx(value(m[i])) assert output.derivatives == {}
def test_csch_d(b): def value(x): return 1 / math.sinh(x) def der(x): return -1 / math.sinh(x) * 1 / math.tanh(x) output = ad.csch(b) assert output.value == pytest.approx(value(b.value)) coef = der(b.value) assert output.derivatives == pytest.approx({ 'x': coef * 1.2, 'y': coef * 9.5, 'z': coef * 5 })
def test_csch_dm(dm): def value(x): return 1 / math.sinh(x) def der(x): return -1 / math.sinh(x) * 1 / math.tanh(x) output = ad.csch(dm) for i in range(len(dm.value)): assert output.value[i] == pytest.approx(value(dm.value[i])) coef = der(dm.value[i]) assert output.derivatives['x'][i] == pytest.approx( coef * dm.derivatives['x'][i]) assert output.derivatives['y'][i] == pytest.approx( coef * dm.derivatives['y'][i]) assert output.derivatives['z'][i] == pytest.approx( coef * dm.derivatives['z'][i])
def test_csch_no_change(b): b_d = b.derivatives output = ad.csch(b) assert b_d == b.derivatives