The matrix entries are yours plus the modifcations I gave you: A[0,0] +=2*shp2[i].X*shp2[i].X+2*shp2[i].Y*shp2[i].Y;
//completing the remaining entries for matrix A
//it is important to note that matrix A is 4 by 4
A[0, 1] += 0;
A[0, 2] += 2 * shp2[i].X;
A[0, 3] += 2 * shp2[i].Y;
A[1, 0] += 0;
A[1, 1] += 2 * shp2[i].Y * shp2[i].Y+2*shp2[i].X*shp2[i].X;
A[1, 2] += 2 * shp2[i].Y;
A[1, 3] += -2 * shp2[i].X;
A[2, 0] += 2 * shp2[i].X;
A[2, 1] += 2 * shp2[i].Y;
A[2, 2] += 2;
A[2, 3] += 0;