@Zachary Nies - I don't think your MAXerror ever gets below the condition. When I run your code, the minimum value assigned to it is
which is still greater
0.000000404848575875934 >= 0.0000001
As an aside, is it necessary to have separate if/elseif conditions for i equal to 1, 2, 3, 4 and 5? Can't you just generalize for even and odd i?