It is unlikely that anyone on this forum has your combination of hardware, so the code can't be tested by us.
You need to figure out why you are getting "inf" as a result.
Place print statements throughout the code to determine which variables do not have the values you expect.