This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def log_add(x, y): | |
maximum = max(x,y) | |
minimum = min(x,y) | |
if(abs(maximum - minimum) > 30): | |
# the difference is too small, return the just the maximum | |
return maximum | |
return maximum + log(1 + pow(2, minimum - maximum) ,2) |