# How to program this in matlab or python: matrices

• Apr 19th 2011, 09:02 AM
jenkki
How to program this in matlab or python: matrices
We are looking at a square in the uv-plane, that we have divided into 10 smaller squares. This means that the large square consists of (10+1)^2 = 121 corners (i,j).

We have a vector, x = (x_1, x_2, ... x_k, ..., x_{121}) = (f(0,0), f(1,0),...,...f(10,10))) where x_k = f(i,j), where k = (i+1) + (10 + 1)j and 1 =< k =< 121 for all 0 =< i, j =< 10 (=< means less or equal to, latex is not working).

Then, for the corners in the midle of the large square, that is; 0 < i, j < 10, the following equation must be satisfied:
f(i, j-1) + f(i-1, j) -4f(i, j) + f(i+1, j) + f(i, j+1) = 0 (1)
This gives us 81 equations on the form: Bx=0

For the corners on the edge of the large square, the following equations must be satisfied:
f(i, 0) = f(0, i) = i and f(i,10) = f(10,i) = 10-i (2)

that is, for all 0 =< i =< 10. This gives us an additional 40 equations, as there are 40 corners around the edge of the large square.

The equations (1) and (2) gives a total of 121 equations that can be written on the form Ax=b. We also wish to have only 1's and -4's on the diagonal.

But how can I make matlab or python find the 121x121 matrix A and the vector b? It seems impossible (Surprised)

Also I could say that the function is: f(u,v) = au^2 + buv + cv^2 + du + ev + h, where a,b,c,d,e,h are constants

Doing this by hand uses the following method: For the equations in (1), I would start with the corner (1,1). The equation would then be:
f(1, 0) + f(0, 1) -4f(1, 1) + f(2, 1) + f(1, 2) = 0
We then see that f(1,0) is the second element i x, and f(1,1) is the 13. element in x (and so on). This means that the second element element in the first row of the matric A we are trying to find is 1, and the 13. element in the first row is -4 (and the first element of b is 0)