Skip to content

Instantly share code, notes, and snippets.

View Puttichai's full-sized avatar

Puttichai Lertkultanon Puttichai

View GitHub Profile
@Puttichai
Puttichai / tupper.py
Created January 22, 2017 05:21
Plotting graphs from Tupper's self-referential formula
import matplotlib.pyplot as plt
def tupper(x, y):
return 0.5 < ((y/h) // 2**(h*x + y%h))%2
# Your value k here
k = 32922520572696913382451905912623623647167183726429121431754312885129411666885193915949745564208638847962779004960137820128309880253556326299620426051843316781711466694127750198822966039318977833943222930199125709567725963414828291187020468933092013936070802306399352123884523508901675580302517101305664361846330981066146182280532463873220739993581702910381088258207784043222527183537656464346321232788544747517684361869138095386938096713005390871951618586863662892224485886579202764210376205132486407529459098019294538104832
h = 17
w = 106
def ReverseTrajectory(topptrajstring):
topptraj = TOPP.Trajectory.PiecewisePolynomialTrajectory.FromString(topptrajstring)
newchunkslist = []
for chunk in topptraj.chunkslist:
T = chunk.duration
newpoly_list = []
for p in chunk.polynomialsvector:
# Perform variable changing of p(x) = a_n(x)^n + a_(n-1)(x)^(n-1) + ...
# by x = T - y