def test_trig2_vector():
    """Boolean condition asserts that value and derivative of a function of the Autodiff class comprising several elementary operations are equal to the expected value and derivative as calculated in the function.

    RETURNS
    ========
    If the boolean condition returns True nothing is returned. If it is computed to be false, then an AssertionError is raised.
    """
    p = [1, 1, 1]
    c = [0.5, 0.5, 3]

    def myfunc(x, y, z):
        a = (EF.sin(x))
        b = (EF.arccos(y))
        c = (EF.tan(z))
        return a + b + c

    f_obj = ADiff(myfunc)
    res = f_obj.pJac(c, p)
    calc_diff = round(res['diff'], 10)
    assert {
        'diff': round(0.7432015404535481, 10),
        'value': math.sin(c[0]) + math.acos(c[1]) + math.tan(c[2])
    } == {
        'diff': round(res['diff'], 10),
        'value': res['value']
    }  #diff values differ at last digits when calculate with math.cos(c[0])- 1/(math.sqrt(1-c[1]**2))+ 1/(math.cos(c[2])*math.cos(c[2]))
def test_vec_func2():
    """Boolean condition asserts that value and derivative of a function of the Autodiff class comprising several elementary operations are equal to the expected value and derivative as calculated in the function.

    RETURNS
    ========
    If the boolean condition returns True nothing is returned. If it is computed to be false, then an AssertionError is raised.
    """

    c = [1, 2]
    p = [1, 1]

    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

    f_obj = ADiff(myfunc)
    res = f_obj.pJac(c, p)

    expectAns = {
        'diff':
        math.pow(2, c[0]) + 1 / (1 + math.exp(-c[1])) *
        (1 - (1 / (1 + math.exp(-c[1])))) + 1 / ((c[1]) * math.log(2)),
        'value':
        math.pow(2, c[0]) + (1 / (1 + math.exp(-c[1]))) + math.log(c[1], 2)
    }

    assert res == expectAns
def test_trig_pJac():
    """Boolean condition asserts that value and derivative of a function of the Autodiff class comprising several elementary operations are equal to the expected value and derivative as calculated in the function.

    RETURNS
    ========
    If the boolean condition returns True nothing is returned. If it is computed to be false, then an AssertionError is raised.
    """
    p = [1]
    c = [0.5]

    def myfunc(x):
        a = (EF.cos(x))
        b = (EF.arcsin(x))
        c = (EF.arctan(x))
        return a - b + c

    f_obj = ADiff(myfunc)
    res = f_obj.pJac(c, p)
    expectAns = {
        'diff':
        -math.sin(c[0]) - (1 / math.sqrt(1 - c[0]**2)) + (1 / (1 + c[0]**2)),
        'value':
        math.cos(c[0]) - math.asin(c[0]) + math.atan(c[0])
    }
    assert res == expectAns