Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pI (self, precision = 2):
- bestCharge = 100000000 #utilizes a large number so the conditional statement is always passed
- bestPH = 0
- PH = 0
- r, l = 14, 0
- x = 0
- p = 1 * (10 ** (-1*precision))
- while l <= r:
- mid = round((l + r)/2,precision)
- thisCharge = self._charge_(mid)
- if abs(thisCharge) < bestCharge :
- bestCharge = abs(thisCharge)
- bestPH = mid
- if thisCharge > 0:
- l = mid + p
- else:
- r = mid - p
- return bestPH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement