Skip to content

Instantly share code, notes, and snippets.

Dmitry dmishin

Block or report user

Report or block dmishin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dmishin
dmishin / sumsin_mpmath.py
Created Oct 31, 2015
Experiments with S(x) = sin(x) + sin(2x)/2 + sin(4x)/4 + ...
View sumsin_mpmath.py
"""Experiments with the 'sumsin' function: maximization and plotting
S(x) = sin(x) + sin(2x)/2 + sin(4x)/4 + ...
it appears that S(x) reaches maximum at
xmax = 0.8905302010175791857059461558*7027*
whereas
36pi/127=0.8905302010175791857059461558*9025*
Plots of the function:
View audio2hilbert.py
#!/usr/bin/env python
#This is Python3 executable
import os.path
from numpy import array, hstack, vstack, clip
from PIL import Image
import numpy as np
import subprocess
import re
#SOX_EXEC = r"C:\Program Files\sox-14-4-2\sox.exe"
@dmishin
dmishin / coprime_fft.py
Created Oct 23, 2014
Generate Fourier transform of the coprime integers map
View coprime_fft.py
#Requires: numpy, PIL
from fractions import gcd
from numpy import array, meshgrid, frompyfunc, clip, histogram
from numpy.fft import fft2
import numpy as np
from PIL import Image
def value_diapason(x, percent=0.95, nbins=100):
"""Use histogram to determine area, covering 95% of values"""
counts, bins = histogram(x.ravel(),nbins)
@dmishin
dmishin / hilbert_image2audio.py
Created Apr 29, 2016
Unwrap imgage pixels into a 1-dimensional array along the Hilbert's curve, then convert it to sound using SOX
View hilbert_image2audio.py
#!/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
@dmishin
dmishin / approx_fractional_iterate.py
Last active Nov 22, 2018
Numerically calculate fractional iterate of x^2-2
View approx_fractional_iterate.py
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):
You can’t perform that action at this time.