For me, using index variable is really the only choice, when solving problem from textbook, which is system of differential equations or just system of equations.
Here is an example from text asking to solve this ODE system

I wanted to check my hand solution is correct. So I use Mathematica to verify. The question now becomes, how to enter that above into Mathematica?
The most direct way is to type 4 differential equations. I want to keep the similar notation to text book to make it easier to compare solution with the book which uses $x_1,x_2,x_3,x_4$ for the variables.
There are 4 options:
- Uses subscripted variables
Subscript[x,1] etc... But these are known to cause problems. - Change the variable names to
x[t],y[t],z[t],w[t] and use these instead. But now the solution will harder to compare to book, as have to remember which new variable match which one used by the book. - use
x1[t],x2[t],x3[t],x4[t] - Use indexed variables.
The reason 4 is better than 3, is because with indexed variable you get much nicer output and the latex generated give true indexed variable $x_1(t)$ which looks much better than $x1(t)$ in the HW report.
Here is an example using option (3) and (4)
Using (3)
ode1 = x1'[t] == x2[t] - x3[t] + x4[t]; ode2 = x2'[t] == -x2[t] + x4[t]; ode3 = x3'[t] == x3[t] - x4[t]; ode4 = x4'[t] == 2*x4[t]; sol = DSolve[{ode1, ode2, ode3, ode4}, {x1[t], x2[t], x3[t], x4[t]}, t]
The latex of the solution looks like

Using (4) (indexed variables)
Quit[] x[n_] := Indexed[x, n]; ode1 = x[1]'[t] == x[2][t] - x[3][t] + x[4][t]; ode2 = x[2]'[t] == -x[2][t] + x[4][t]; ode3 = x[3]'[t] == x[3][t] - x[4][t]; ode4 = x[4]'[t] == 2*x[4][t]; sol = DSolve[{ode1, ode2, ode3, ode4}, {x[1][t], x[2][t], x[3][t], x[4][t]}, t]
The Latex of the solution looks like

Which looks much better and will make the teacher more happy.
Solve[a[1]^2==2, a[1]]but you can'tSolve[a[[1]]^2==2, a[[1]] ]. This is what we typically use when we don't know the number of symbolic variables we need beforehand. I would sometimes define a 3 by 3 matrix with explicit symbolic elements asArray[a, {3,3}]. $\endgroup$