Julia is column-major while your implementation seems to be for a row-major case. The code works as expected if we swap the indexing of the matrices:
Code revised
A = [10. -1 2 0
-1 11 -1 3
2 -1 10 -1
0 3 -1 8]
B = [6., 25, -11, 15]
initial = [0., 0, 0, 0]
maxIterations = 1000
tolerance = 1*10^-6
dimension = length(initial)
coefficentMatrix = zeros(Float64,length(initial),length(initial) + 1)
for index in CartesianIndices(coefficentMatrix)
if index[1] == index[2]
coefficentMatrix[index[2],length(initial)+1] = B[index[2]] / A[index[2],index[2]]
elseif index[2] != (length(initial) + 1)
coefficentMatrix[index[2],index[1]] = -A[index[2],index[1]] / A[index[2],index[2]]
end
end
iteration = 1
while iteration < maxIterations
aproximation = Float64[]
for row in eachrow(coefficentMatrix)
push!(aproximation,sum(row[1:dimension] .* initial[:,iteration]) + row[dimension+1])
end
iteration += 1
initial = hcat(initial,aproximation)
end
initial