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
from bigfloat import * | |
N = 5 | |
setcontext(precision(10**N)) | |
def f(x): | |
return x + sin(x) | |
def g(n): | |
x = 3 | |
for i in xrange(n): |
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 | |
from scipy import * | |
from pylab import * | |
class pinum(object): | |
def __init__(self,z): | |
self.z = z | |
self.logz = math.log10(z) | |
self.pow, self.rest = divmod(self.logz,1) | |
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
#Figure out some primes in consecutive digits of pi | |
from sympy import * | |
N = 1000 | |
pidigits = ["3"] + list(str(pi.evalf(N)))[2:] | |
for end in xrange(1,N-1): | |
candidate = int("".join(pidigits[:end])) | |
if int(pidigits[end]) >= 5: | |
rounded = candidate + 1 | |
if isprime(rounded): |
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 scipy as sp | |
import pylab as py | |
def chi_sq(x, y, y_err, a_vals, b_vals): | |
chi_min = 10000. | |
a_best = -1000. | |
b_best = -1000. | |
for a in a_vals: | |
for b in b_vals: | |
fit = a * x + b |