IOU is non-zero only when the numerator is non-zero, so you know the problem is with the intersection element. There is a diagram in this thread that might help you work through this test case by hand. Try drawing it out and computing the intersection manually, then compare to your code.