You might find it simpler to reverse to so that your vector is and reverse the order of the points. that will make equal to

which, at least, lets you start with smaller numbers. (Note the "3" in the upper left. Recheck the calculation that gave you that "4".)