Sorry Bill, I didn't participate in the conversation over the long weekend. (I wish I could say I was hiking but I can't use that excuse). It sounds like you got your math questions answered. Let me know if you have some lingering questions. I didn't quite understand the problem you ran into with your subroutine. I know a bit about coding but I don't know the language you are using. Let me know if I can help further.

p.s. it looks like your question on powers was answered, but I just wanted to add: from a programming perspective it is more efficient to program "x^2" as "x*x" instead of "x**2". It probably won't make any difference for your program, but I thought I would pass along one of the few nuggets of wisdom I have on programming.