# Why do I keep getting the same time from the Timing function?

I am running a gamblers problem solution where I am testing the timing involved in solving the Ax = b equation for matrices of n=100, 1000, 10000, and 100000. For some reason I keep getting the same time (0.015625 seconds) for the time, but I know it takes many more seconds than this. The matrix for n=100000 ran for probably 20 mins and still returned 0.015625.

My process to create the matrix is basically:

 A = IdentityMatrix[100000, SparseArray];
For[i = 2, i < 100000, i++,
A[[i, i]] = -1;
A[[i, i - 1]] = .5;
A[[i, i + 1]] = .5
];


The vector is created by:

b = {1};
For[i = 2, i <= 100000, i++, b = Insert[b, 0, -1] ];


Then I run:

Timing[LinearSolve[A, b]]

• What are matrixSize, vectorSize and coefficientMatrix? – Henrik Schumacher Mar 14 '19 at 22:34
• Sorry, I removed those variables. – Jaigus Mar 14 '19 at 22:42
• What happens if you use AbsoluteTiming instead of Timing? – Michael E2 Mar 14 '19 at 22:42
• – Michael E2 Mar 14 '19 at 22:44
• AbsoluteTiming doesn't give me the same number anymore, yet it still gives a very small number. – Jaigus Mar 14 '19 at 22:59

I cannot tell what the problem with the timing is but I can show you how to set up and solve the system quicker:

First@AbsoluteTiming[
n = 100000;
A = SparseArray[{
Band[{1, 1}] -> -1.,
Band[{2, 1}] -> 0.5,
Band[{1, 2}] -> 0.5
},
{n, n}];
b = Normal[SparseArray[{1} -> 1., {n}]];
x = LinearSolve[A, b];
]


0.665885