# Solving a system of linear equations stored in a table

I have a system of $n$ linear equations with an equal or smaller number of unknowns stored in a table. The variables are of the form $f[x_1,x_2,x_3]$. For example, the equations are:

f[1,1,1]= 2f[3,2,1] + 4f[2,1,1]
f[1,4,2] = 3f[1,3,1] + 3f[2,4,1] + 3ab
.....


I need to solve those equations for f[1,1,1], f[1,1,2],... in terms of a, b, ... and other constants.

Solve[f[i,j,k]==0, {f[i,j,k], {i,m}, {j,m}, {k,m}}] doesn't work.

Any help is appreciated.

There seem to be two separate questions here, perhaps. The first is, how can one solve an equation in indexed variables? The answer is, like with any other variables. The second question is, how can I produce the list of variables needed by solve? The answer is, any way you would usually produce a list.

ClearAll[f]
vars = Array[f[##] &, 2]
eq1 = f[1] + f[2] == 1
eq2 = f[1] - f[2] == 1
Solve[eq1 && eq2, vars]

• Thanks. Is there a way of storing the solution as the variables' values? For example, f[5] -> 8 so f[5] will have a value of 8 and so on?
– Bran
Nov 18, 2017 at 22:54
• @Subzero-273K Yes, you can ReplaceAll[solns, {Rule -> Set}], but generally it is better not to do this.
– Alan
Nov 19, 2017 at 16:04