Created
January 25, 2018 20:41
-
-
Save seemikehack/b41253cecdc07aabac0acfc9e5b1077c to your computer and use it in GitHub Desktop.
Calculate constants for use in mapping a linear scale to a logarithmic scale
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
import math | |
x1 = int(input('lin beg: ')) | |
x2 = int(input('lin end: ')) | |
y1 = int(input('log beg: ')) | |
y2 = int(input('log end: ')) | |
b = math.log( ( y2 / y1 ) / ( x2 - x1 ) ) | |
a = y2 / math.exp( b * x2 ) | |
print('y = a exp bx, where:') | |
print('a = ' + str(a)) | |
print('b = ' + str(b)) | |
print('sanity check:') | |
print(str(y1) + ' == ' + str(a * math.exp ( b * x1 ))) | |
print(str(y2) + ' == ' + str(a * math.exp ( b * x2 ))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment