bear with me as I'm very inexperienced with Mathematica, although I think my problem is reasonably straight forward:
I'm currently trying to find a matrix from a simple expression. I've found a way to extract the matrix, however there still remains a constraint that I must somehow impose in order for the matrix to be correct. Here is what I have:
nn = 10;
row[n_] := Sum[(p + 1 + R + 3 n^2) a[p], {p, 0, nn - 1}] + \[Alpha] a[n - 1]
vector = Table[a[i], {i, 0, nn - 1}];
matrix = Table[D[row[i], vector[[j]]], {i, 1, nn}, {j, 1, nn}]
This produces a matrix which is fantastic. However, I still have two "boundary conditions" left to impose which are (written in Mathematica code):
Sum[a[n],{n,0,nn-1}]=0
Sum[n^2a[n],{n,0,nn-1}]=0
Does anyone have any ideas of how I can impose these constraints upon the above set of code, such that the end matrix takes them into account?
Thank you :)
Edit:
nn = 10;
row[n_] := Sum[(p + 1 + R + 3 n^2) a[p], {p, 0, nn - 1}] + \[Alpha] a[n - 1]
vector = Table[a[i], {i, 0, nn - 1}];
matrix = Table[D[row[i], vector[[j]]], {i, 1, nn}, {j, 1, nn}]
matrix /. { a[0] -> -Sum[i^2 a[i],{i,2,nn-1}] - Sum[a[i],{i,1,nn-1}], a[1] -> -Sum[i^2 a[i],{i,2,nn-1}]}