I have an $n$ x $n$ matrix $T$, where $t_{ij}$ is the element at the $i\,$th row and $j\,$th column, and unknowns $x_i$, $1\leq i \leq n$, where
$$x_{n} = 1$$
$$x_{n-1} = 0$$
$$x_i = \sum_{1\leq j \leq n}{t_{ij}x_j};\;1\leq i \leq n-2$$
and am trying to package up this problem statement for use in LinearSolve
. I can get everything working satisfactorily with
LinearSolve[T - DiagonalMatrix[Join[Table[1, {n - 2}], {0, 0}]], Append[Table[0, {n - 1}], 1]]
but feel like I've made things more complicated than they need to be.
Is there a better, more compact — perhaps more idiomatic — way to express this problem?