Alternatives to using LinearSolve

mat =
Table[
If[i == j, .5, If[i == j - 1 || i == j + 1, .25, 0]], {i, 1, 100}, {j, 1, 100}];
b = Table[1./i, {i, 1, 100}];
old = Table[1, {i, 1, 100}];
new = Table[1, {i, 1, 100}];
dim = 100;
actual = LinearSolve[mat, b];


I want to find different ways to get the actual value without using the LinearSolve command.

• You could always use Inverse to compute the inverse of mat, but in most situations LinearSolve is preferable. Oct 21, 2019 at 8:11
• This is just a tridiagonal matrix with constant elements. Analytic solution is available. See here iopscience.iop.org/article/10.1088/0305-4470/29/7/020/meta Oct 21, 2019 at 9:34
• You can use actual = Inverse[mat].b as Sjoerd Smit has commented.
– Sâu
Oct 22, 2019 at 15:09

I want to find different ways to get the actual value without using the LinearSolve command

You can use Solve

ClearAll[x,i,j];
mat = Table[If[i == j, .5, If[i == j - 1 || i == j + 1, .25, 0]], {i, 1, 100}, {j, 1, 100}];
b = Table[1./i, {i, 1, 100}];

vars = Table[x[i], {i, Length@b}];
Solve[eqs, vars]


Compare to

actual=LinearSolve[mat,b]