def matrix_find_eigenvalues(matrix):
    eigenvalues = []
    eigenvalues.append(
        matrix_inverse_power_iteration(matrix, 0.0, 0.00000000000001, 20000))
    eigenvalues.append(matrix_power_iteration(matrix, 0.0000000001, 20000))
    find_middle_eigenvalue(matrix, eigenvalues, eigenvalues[0], eigenvalues[1])
    return eigenvalues
def hilbert_matrix_power_iteration_test():

    selection = [4, 6, 8, 10]
    hilbert_matrix = []
    solution = []

    # Create the hilbert matrices and their corresponding Q factorization matrix.
    for n in selection:
        hilbert_matrix.append([[1 / (1 + i + j) for i in range(n)]
                               for j in range(n)])  # Hilbert Matrix generator
        solution.append(
            matrix_power_iteration(hilbert_matrix[-1], 0.000000001, 10000))

    for i in range(0, len(selection)):  # 4, 6, 8, 10
        #print(matrix_mult(hilbert_matrix[i],convert_vec_mat(solution[i])))
        print("Largest Eigen Value for " + str(selection[i]) + "x" +
              str(selection[i]) + ": " + str(solution[i]))
def matrix_condition_number(matrix):
    smallest_eigenvalue = matrix_inverse_power_iteration(
        matrix, 0, 0.00000000000001, 20000)
    largest_eigenvalue = matrix_power_iteration(matrix, 0.0000000001, 20000)
    return abs(largest_eigenvalue / smallest_eigenvalue)