Add function to calculate 1/x, returning inf if x is zero.