<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def projection(x, A, b):
 """ Returns the vector xhat closest to x in 2-norm, satisfying A.xhat =b. :param x: vector :param A, b: matrix and array characterizing the constraints on x (A.x = b) :return x_hat: optimum angle vector, minimizing cost. :return cost: least square error of xhat, x :return constraints_error: mse of constraint. :rtype: (numpy.ndarray, float, float) """

    A_pseudoinv = pseudo_inverse(A)
    tmp_ = A.dot(x)
    tmp_ -= b
    x_hat = A_pseudoinv.dot(tmp_)
    np.subtract(x, x_hat, out=x_hat)

    cost = mse(x_hat, x)
    A.dot(x_hat, out=tmp_)
    constraints_error = mse(tmp_, b)
    return x_hat, cost, constraints_error