Hi Timothy,
The code is not converging and completing the max iteration steps(3000). This is happening as the "residual (lhs - rhs)" is of much higher order and failing the check “abs(residual) < tolerance” if tolerance is 1e-6.
To solve it there can be two approaches:
1. Keep the tolerance at higher order, around 100(<0.1% of LHS)
2. Increase the "max_iter" to a higher value and decrease the increment of "B". This will give a more accurate value of B but will take more time to calculate.
Result when values at max_iter=30000000, tolerance=1e-2 and increment of B by B = B + 0.0000001
Hope it helps.