# 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. – Sjoerd Smit Oct 21 '19 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 – yarchik Oct 21 '19 at 9:34
• You can use actual = Inverse[mat].b as Sjoerd Smit has commented. – Sâu Oct 22 '19 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}]; actual=LinearSolve[mat,b] 