def test_2():
    '''
    Testing sin(cos(x)) derivative and value
    '''
    x = AD.AADVariable((math.pi))
    x = AD.sin(AD.cos(x))
    #value check
    assert abs(x.val - math.sin(math.cos(math.pi))) < tol
    #derivative check
    assert abs(x.der -
               (-math.cos(math.cos(math.pi)) * math.sin(math.pi))) < tol
def test_8():
    '''
    Testing 2*cos(x) derivative and value
    This also tests __rmul__ overrides
    '''
    x = AD.AADVariable((math.pi))
    x = 2 * AD.cos(x)
    #value check
    assert abs(x.val - 2 * math.cos(math.pi)) < tol
    #derivative check
    assert abs(x.der + 2 * math.sin(math.pi)) < tol
def test_9():
    '''
    Testing 2/cos(x) derivative and value
    This also tests __rciv__ overrides
    '''
    x = AD.AADVariable((math.pi))
    x = 2 / AD.cos(x)
    #value check
    assert abs(x.val - 2 / math.cos(math.pi)) < tol
    #derivative check
    assert abs(x.der + 2 * math.tan(math.pi) / math.cos(math.pi)) < tol
def multiVariable1():
    '''
    Tests Gradient Descent with multiple variables
    '''
    x = AD.AADVariable(3, [1, 0])
    y = AD.AADVariable(2, [0, 1])

    solve = AAD_grad.solve(lambda X: AD.abs(AD.cos(X[0]) * X[1] - 12), [x, y],
                           0.001,
                           progress_step=None,
                           max_iter=10000)
    assert (solve[0].val < tol and solve[1].val - 12 < tol)