use math.log and math.pow instead of np.log and np.pow as they seem far faster, at least on scalars