def METHOD_NAME(A, B, Q, R):
    """
    Solve the discrete time lqr controller.
    x[k+1] = A x[k] + B u[k]
    cost = sum x[k].T*Q*x[k] + u[k].T*R*u[k]
    # ref Bertsekas, p.151
    """
    # first, try to solve the ricatti equation
    P = solve_DARE(A, B, Q, R)
    # compute the LQR gain
    K = inv(B.T @ P @ B + R) @ (B.T @ P @ A)
    eigVals, eigVecs = eig(A - B @ K)
    return K, P, eigVals