I have written the following Mathematica codes to solve the LAPLACE eq. using the finite differences method.

` In[1]:= Remove[a, b, Nx, Ny, h, xgrid, ygrid, u, i, j] a = 0; b = 0.5; n = 4; h = (b - a)/n; xgrid = Table[x[i] -> a + i h, {i, 1, n}]; ygrid = Table[y[j] -> a + j h, {j, 1, n}]; eqnstemplate = {-4 u[i, j] + u[i + 1, j] + u[i - 1, j] + u[i, j - 1] + u[i, j + 1] == 0}; BC1 = Table[u[i, 0] == 0, {i, 1, n - 1}]; BC2 = Table[u[i, 4] == 200 x[i], {i, 1, n - 1}]; BC3 = Table[u[4, j] == 200 y[j], {j, 2, n - 1}]; BC4 = Table[u[0, j] == 0, {j, 2, n - 1}]; Eqns = Table[eqnstemplate, {i, 1, n - 1}, {j, 1, n - 1}] /. xgrid /. ygrid // Flatten; systemEqns = Join[Eqns, BC1, BC2, BC3, BC4] /. xgrid /. ygrid Out[12]= {u[0, 1] + u[1, 0] - 4 u[1, 1] + u[1, 2] + u[2, 1] == 0, u[0, 2] + u[1, 1] - 4 u[1, 2] + u[1, 3] + u[2, 2] == 0, u[0, 3] + u[1, 2] - 4 u[1, 3] + u[1, 4] + u[2, 3] == 0, u[1, 1] + u[2, 0] - 4 u[2, 1] + u[2, 2] + u[3, 1] == 0, u[1, 2] + u[2, 1] - 4 u[2, 2] + u[2, 3] + u[3, 2] == 0, u[1, 3] + u[2, 2] - 4 u[2, 3] + u[2, 4] + u[3, 3] == 0, u[2, 1] + u[3, 0] - 4 u[3, 1] + u[3, 2] + u[4, 1] == 0, u[2, 2] + u[3, 1] - 4 u[3, 2] + u[3, 3] + u[4, 2] == 0, u[2, 3] + u[3, 2] - 4 u[3, 3] + u[3, 4] + u[4, 3] == 0, u[1, 0] == 0, u[2, 0] == 0, u[3, 0] == 0, u[1, 4] == 25., u[2, 4] == 50., u[3, 4] == 75., u[4, 2] == 50., u[4, 3] == 75., u[0, 2] == 0, u[0, 3] == 0} `

I need this out put in matrix form just for the unknown variable with substituting the known value to get the linear system that arises from solving the laplacses eq.