def test_csc(): """Boolean condition asserts that value and derivative of the cosecant of the AutoDiff instance are equal to the expected value and derivative as calculated in the function for the case in which x is a real number. RETURNS ======== If the boolean condition returns True nothing is returned. If it is computed to be false, then an AssertionError is raised. """ c = 14 assert { 'diff': EF.csc(c).der, 'value': EF.csc(c).val } == { 'diff': 0, 'value': 1 / math.sin(c) }
def test_tanh_con(): """Boolean condition asserts that value and derivative of the hyperbolic tangent of the AutoDiff instance are equal to the expected value and derivative as calculated in the function for the case in which x is a real number. RETURNS ======== If the boolean condition returns True nothing is returned. If it is computed to be false, then an AssertionError is raised. """ c = 14 assert { 'diff': EF.tanh(c).der, 'value': EF.tanh(c).val } == { 'diff': 0, 'value': ((math.exp(c) - math.exp(-c)) / 2) / ((math.exp(c) + math.exp(-c)) / 2) }
def logtarget(*arg): return EF.log(target(*arg))
def target(x, y): return EF.exp(-(1 - x)**2 - 10 * (y - x**2)**2)
def myfunc(x): f1 = EF.exp(x) return f1
def myfunc(x): f1 = EF.cos(x) return f1
def myfunc(x, y): a = EF.exp_base(2, x) #base 2 and exponent x b = EF.logistic(y) c = EF.log(y, 2) #log with base 2 return a + b + c
def myfunc(x, y): f1 = x * y f2 = EF.sin(x) f3 = 10 f4 = x + y + EF.sin(x * y) + 10 return [f1 + f2, -(f3 - f4)]
def myfunc(x, y, z): a = (EF.sin(x)) b = (EF.arccos(y)) c = (EF.tan(z)) return a + b + c
def myfunc(x): a = (EF.cos(x)) b = (EF.arcsin(x)) c = (EF.arctan(x)) return a - b + c
def myfunc(x): f1 = EF.sin(x) return f1
def myfunc(x): f1 = EF.sec(x) return f1
def myfunc(x): f1 = EF.log(x) return f1
def myfunc(x): f1 = EF.tanh(x) return f1