Ick! You used the box method. I hate that silly thing. Even though it's exactly the same as the integration method, I still hate it. Grr.
Also, after spending five seconds looking over it, it looks like you're using a rather imprecise method. I'm afraid this just won't work well without the fundamental theorem or limits, neither of which can be easily emulated in Ruby.