  import numpy as np
import scipy.sparse as sparse
import scipy.sparse.linalg as linalg
import matplotlib.pyplot as plt
import argparse

# Parse command line arguments
parser = argparse.ArgumentParser()
parser.add_argument("--degree", type=int, default=1)
parser.add_argument("--max_iter", type=int, default=10)
parser.add_argument("--adaptive", type=float, default=0.1)
args = parser.parse_args()

# Initialize problem
pde = "u_xx + u_yy = 0"
domain = [0, 1, 0, 1]

# Set up error matrix and mesh
error = np.zeros((args.max_iter, 1))
mesh = np.zeros((args.max_iter, 2))

# Enter loop for maximum number of iterations
for i in range(args.max_iter):
    # Set up VEM space and function
    vem_space = np.zeros((args.degree + 1, 2))
    vem_space[0, :] = 1
    vem_space[1, :] = np.array([-1, 1])
    vem_space[2, :] = np.array([-1, 1])
    vem_space[3, :] = np.array([-1, 1])
    vem_space[4, :] = np.array([-1, 1])
    vem_space[5, :] = np.array([-1, 1])
    vem_space[6, :] = np.array([-1, 1])
    vem_space[7, :] = np.array([-1, 1])
    vem_space[8, :] = np.array([-1, 1])
    vem_space[9, :] = np.array([-1, 1])
    vem_space[10, :] = np.array([-1, 1])
    vem_space[11, :] = np.array([-1, 1])
    vem_space[12, :] = np.array([-1, 1])
    vem_space[13, :] = np.array([-1, 1])
    vem_space[14, :] = np.array([-1, 1])
    vem_space[15, :] = np.array([-1, 1])
    vem_space[16, :] = np.array([-1, 1])
    vem_space[17, :] = np.array([-1, 1])
    vem_space[18, :] = np.array([-1, 1])
    vem_space[19, :] = np.array([-1, 1])
    vem_space[20, :] = np.array([-1, 1])
    vem_space[21, :] = np.array([-1, 1])
    vem_space[22, :] = np.array([-1, 1])
    vem_space[23, :] = np.array([-1, 1])
    vem_space[24, :] = np.array([-1, 1])
    vem_space[25, :] = np.array([-1, 1])
    vem_space[26, :] = np.array([-1, 1])
    vem_space[27, :] = np.array([-1, 1])
    vem_space[28, :] = np.array([-1, 1])
    vem_space[29, :] = np.array([-1, 1])
    vem_space[30, :] = np.array([-1, 1])
    vem_space[31, :] = np.array([-1, 1])
    vem_space[32, :] = np.array([-1, 1])
    vem_space[33, :] = np.array([-1, 1])
    vem_space[34, :] = np.array([-1, 1])
    vem_space[35, :] = np.array([-1, 1])
    vem_space[36, :] = np.array([-1, 1])
    vem_space[37, :] = np.array([-1, 1])
    vem_space[38, :] = np.array([-1, 1])
    vem_space[39, :] = np.array([-1, 1])
    vem_space[40, :] = np.array([-1, 1])
    vem_space[41, :] = np.array([-1, 1])
    vem_space[42, :] = np.array([-1, 1])
    vem_space[43, :] = np.array([-1, 1])
    vem_space[44, :] = np.array([-1, 1])
    vem_space[45, :] = np.array([-1, 1])
    vem_space[46, :] = np.array([-1, 1])
    vem_space[47, :] = np.array([-1, 1])
    vem_space[48, :] = np.array([-1, 1])
    vem_space[49, :] = np.array([-1, 1])
    vem_space[50, :] = np.array([-1, 1])
    vem_space[51, :] = np.array([-1, 1])
    vem_space[52, :] = np.array([-1, 1])
    vem_space[53, :] = np.array([-1, 1])
    vem_space[54, :] = np.array([-1, 1])
    vem_space[55, :] = np.array([-1, 1])
    vem_space[56, :] = np.array([-1, 1])
    vem_space[57, :] = np.array([-1, 1])
    vem_space[58, :] = np.array([-1, 1])
    vem_space[59, :] = np.array([-1, 1])
    vem_space[60, :] = np.array([-1, 1])
    vem_space[61, :] = np.array([-1, 1])
    vem_space[62, :] = np.array([-1, 1])
    vem_space[63, :] = np.array([-1, 1])
    vem_space[64, :] = np.array([-1, 1])
    vem_space[65, :] = np.array([-1, 1])
    vem_space[66, :] = np.array([-1, 1])
    vem_space[67, :] = np.array([-1, 1])
    vem_space[68, :] = np.array([-1, 1])
    vem_space[69, :] = np.array([-1, 1])
    vem_space[70, :] = np.array([-1, 1])
    vem_space[71, :] = np.array([-1, 1])
    vem_space[72, :] = np.array([-1, 1])
    vem_space[73, :] = np.array([-1, 1])
    vem_space[74, :] = np.array([-1, 1])
    vem_space[75, :] = np.array([-1, 1])
    vem_space[76, :] = np.array([-1, 1])
    vem_space[77, :] = np.array([-1, 1])
    vem_space[78