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
s="3248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272734324333248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272733248734278923478923478932798324734287932988934822872347243772437743272733248734 |
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 numpy as np | |
N = 300 #size of the grid | |
M = 20000 #number of pixels | |
potential = np.zeros((N, N), dtype=np.float64) | |
masses = np.zeros((N, N), dtype=np.bool8) | |
def potential_of_mass_at(i, j): | |
"""Returns L1 potential of a mass at (i, j) with mass m | |
potential is calcualted as: |
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 scipy.optimize import linprog | |
import numpy as np | |
import itertools | |
#Searching for the counterexample for the following conjecture: | |
# in the shortest hamiltonian path, there is at least one | |
# node, connected to its 12 nearest neighbors | |
# https://www.reddit.com/r/math/comments/17rxc28/travelling_salesman_algorithm/ | |
# Use linear programming to find a counterexample |
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
"""Calculate smooth iterates of the function | |
f:[0,1]->[0,1] | |
f(x) = 1-sqrt(1-x^2) | |
https://mathoverflow.net/questions/449748/what-are-the-iterates-of-x-mapsto-1-sqrt1-x2 | |
https://twitter.com/gro_tsen/status/1674132770203881477 | |
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 numpy as np | |
from matplotlib import pyplot as plt | |
import scipy | |
def ht(n:int)->np.array: | |
"""Generates Thue-Morse sequence, arranged along the Hilbert curve of order N. Result is (2**n, 2**n) matrix""" | |
if n < 0: raise ValueError("Bad order") | |
if n == 0: | |
return np.array([[1]], dtype=np.int8) | |
else: |
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
$("#run").click(() => tryCatch(run)); | |
async function run() { | |
Excel.run(async function (context) { | |
var sctivesheet = context.workbook.worksheets.getActiveWorksheet(); | |
var table = sctivesheet.tables.add(sctivesheet.getRangeByIndexes(0, 0, 1, 2), true); | |
var data = [[1, "A"], [2, "B"], [3, "C"]]; | |
table.rows.add(0, data); | |
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
#%metadata% | |
#url: https://twitter.com/diegorattaggi/status/1252654580720119810/photo/1 | |
from sympy import * | |
mfib = Matrix([[0,1],[1,1]]) | |
fib0 = Matrix([0,1]) | |
luc0 = Matrix([2,1]) | |
eye = Matrix([[1,0],[0,1]]) | |
def fibo(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 numpy as np | |
import scipy as sp | |
import scipy.linalg | |
from math import floor, pi | |
#Detect optimal step for minimal order Schreiber test signal | |
#Set to False to disable printing | |
_verbose = True |
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 approxfi(x, n): | |
#Apply x -> F(x) mapping until x is sufficiently large | |
k = 0 | |
while (x < 1e14) and (k<100): | |
x = x**2-2 | |
k += 1 | |
#Calculate approximate fractional iterate for large argument | |
x = x**(2**n) | |
#Apply reverse mapping x -> F[-1](x) | |
for _ in range(k): |
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
#!/usr/bin/env python | |
from __future__ import print_function, division | |
import os.path | |
from numpy import array, hstack, vstack, clip | |
from PIL import Image | |
import numpy as np | |
import subprocess # need the subprocess module | |
from tempfile import mkdtemp | |
import shutil |
NewerOlder