You get a divide by zero either when mu=0 or when mu=1. It's clear that as mu approaches 1, b(mu) approaches 0, so that's easy to fix. However, as mu approaches 0, b(mu) rises asymptotically to infinity, and when mu =0, b(mu) is undefined. So the real solution is to not calculate b(mu) for mu =0, because it's meaningless. If you don't want to do that, then make the function return NaN for mu=0.
↧