Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from decimal import *
- d = Decimal
- getcontext().prec = 256
- #e = d(e) #this is inaccurate
- pi = d(pi) #we actually don't need a fully accurate estimate of e, the entire thing converges even
- #with just an aproximation
- e=d('2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274274663919320030599218174135966290435729003342952605956307381323286279434907632338298807531')
- #should write an override of d, that takes in a space separated string, or even a comma delimited version,
- #or an underscore delimited version, and simply detects and removes the delimiters, before returning
- #a relevant Decimal() instance with that value.
- def est_e(limit = 20, F=None, E=None):
- x = d('1.391925581569705')
- if F == None:
- _f = d('596.25') #596.25
- else:
- _f = F
- if E == None:
- _e = (((1/(((((1/(x.ln() / (pi-d('0.5')).ln()))-1))-1)*(x-1)))-(1/((((1/_f)*17)+17)**2))))
- else:
- _e = E
- i = 0
- while i < limit:
- v = (1/((_e).ln()-1)).ln()
- _e = ((((1/(((((1/(x.ln() / (pi-d('0.5')).ln()))-1))-1)*(x-1)))-(1/((((1/_f)*17)+17)**2)))) - (1/(_e**v)))
- _f = 1/((((1/((1/(((((1/(x.ln() / (pi-d('0.5')).ln()))-1))-1)*(x-1)))-_e)).sqrt())/17)-1)
- i = i + 1
- print("done!")
- print(f"estimate e: {_e}, actual: {e}, ratio: {_e/e}, F: {F}")
- return _f, _e
- #Edited slightly for those who want to do something like...
- F, E = est_e(1, d(1))
- #and then
- i = 0
- somelimit = 10000
- while i < somelimit:
- F, E = est_e(1, F, E)
- i = i + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement