Implement an algorithm in Python to optimize the following cost function
cost(x) = 3x^2 + 4x +2
def optimization_algorithm(x): 
    cost = 3 * x ** 2 + 4*x + 2
    while cost > 0: 
        cost = cost - (6*x + 4)
        x = x - 0.01
    return x