Skip to content

Instantly share code, notes, and snippets.

View chakravala's full-sized avatar
🧐
infamous researcher and mathemalinguist

Dream Scatter chakravala

🧐
infamous researcher and mathemalinguist
View GitHub Profile
@chakravala
chakravala / ramanujan-tau.png
Last active June 7, 2022 21:48
Ramanujan's tau function (100 years of) -> a python script
ramanujan-tau.png
@chakravala
chakravala / jones-prime-formula.jl
Created September 15, 2017 19:59
Jones formula for n-th prime
g(y::BigInt,x::BigInt) = BigInt((abs(y-x) + y-x)//2)
r(y::BigInt,x::BigInt)::BigInt = (x==0) ? y : mod(y,x)
p(n::Int) = sum(i->g(BigInt(1),g(sum(j->r((factorial(g(BigInt(j),BigInt(1))))^2,BigInt(j)),0:i),BigInt(n))),0:n^2)
map(p,1:17)
@chakravala
chakravala / tamari-grove-commutativity.jl
Last active October 22, 2017 21:15
Visualize dendriform grove sum commutativity using Tamari associahedron
using Dendriform, LightGraphs, GraphPlot, Colors
function highlight_sum(a::Grove,b::Grove)
d = a.degr + b.degr
g = DiGraph(Int(Cn(d)))
for i = 1:Int(Cn(d))
u = Dendriform.posetnext(PBTree(d,i))
for t in u
add_edge!(g,i,treeindex(t))
end
end
@chakravala
chakravala / grove-iterator.jl
Created October 22, 2017 20:21
Creates iterable function object for Dendriform.Grove
using Dendriform, ResumableFunctions
@resumable function trees(g::Union{Grove,PBTree})
typeof(g) == PBTree && return ResumableFunctions.@yield g
for i 1:g.size-1
ResumableFunctions.@yield PBTree(g.Y[i,:])
end
return PBTree(g.Y[end,:])
end
import Base.convert
convert(::Type{Array{PBTree,1}},g::Grove) = [trees(g)...]
using Grassmann;
@basis D"1,1,1,0";
P = [ rand()*v124 + rand()*v134 + rand()*v234 + v123 for i=1:1000 ];
L = [ rand()*v12 + rand()*v13 + rand()*v14 + rand()*v23 + rand()*v24 + rand()*v34 for i=1:1000 ];
A = [ rand() for i=1:1000];
test2(L,A,P) = (LA = exp.(L.*A); LA.*P.*.~LA);
R = test2(L,A,P);
f(L,A,P,i) = (LA = exp(L[i]*A[i]); LA*P[i]*~LA);
function test(L,A,P,R)
for k 1:1000