# load the package badic (you can install it with "sage -pip install badic [--user]")
from badic import *
# the dragon fractal
m = BetaAdicSet(1/(1+I),[0,1])
m.plot()
# words starting by 0 that can be prolongated infinitly
# to reach an infinite word starting by 1
mi = m.intersection_words([0], [1])
mi.plot(nprec=6)
# automaton describing this beta-adic set
mi.a.plot()
# Minkowski-Bouligand dimension of this beta-adic set
mi.critical_exponent()
# the dragon fractal cannot be a Rauzy fractal
# because the number beta=1/(1+I) is not Pisot
m.substitution()
# compute the dimension of the boundary of a Rauzy fractal
s = WordMorphism('a->ab,b->ac,c->a')
m = DumontThomas(s).mirror()
mi = m.intersection_words([0],[1])
mi.critical_exponent()
# part of the boundary
mi.plot()
# compute the dimension of the boundary of a Rauzy fractal
s = WordMorphism('a->ab,b->ca,c->a') # flipped Tribonnacci
m = DumontThomas(s).mirror()
mi = m.intersection_words([0],[1])
mi.critical_exponent()
# compute the dimension of the boundary of a Rauzy fractal
s = WordMorphism('a->b,b->c,c->ab') # smallest Pisot
m = DumontThomas(s).mirror()
m.plot()
# words starting by 0 that can be prolongated infinitly
# to reach an infinite word starting by 1
# (describe a part of the boundary)
mi = m.intersection_words([0],[1])
print(mi)
mi.plot()
# Minkowski-Bouligand dimension of the boundary of the Rauzy fractal
# (the exact computation is very long, but this approximation is fast)
sp = mi.a.spectral_radius(approx=True)
print(sp)
print("dim = %s" % (-log(sp)/log(abs(mi.b))))
# A beta-adic set
# the plot is not really clean because points are described by many words
m = BetaAdicSet(x^4-x^2-x-1, [0,1])
m.plot()
# describe elements of the beta-adic set by unic words for a given length
m = m.reduced()
m.plot()
# words starting by 0 that can be prolongated infinitly
# to reach an infinite word starting by 1
mi = m.intersection_words([0],[1])
mi.plot()
# Minkowski-Bouligand dimension of the boundary
mi.critical_exponent()
# A beta-adic set
# the plot is not really clean because points are described by many words
m = BetaAdicSet(x^4-x^3-x^2-1, [0,1])
m.plot()
# describe elements of the beta-adic set by unic words for a given length
m = m.reduced()
m.plot()
# words starting by 0 that can be prolongated infinitly
# to reach an infinite word starting by 1
mi = m.intersection_words([0],[1])
mi.plot()
# Minkowski-Bouligand dimension of the boundary
mi.critical_exponent()
# A beta-adic set
# the plot is not really clean because points are described by many words
m = BetaAdicSet(x^5-x^3-x^2-1, [0,1])
m.plot()
# describe elements of the beta-adic set by unic words for a given length
m = m.reduced()
m.plot()
# words starting by 0 that can be prolongated infinitly
# to reach an infinite word starting by 1
mi = m.intersection_words([0],[1])
mi.plot()
# Minkowski-Bouligand dimension of the boundary
mi.critical_exponent()
# A beta-adic set
# the plot is not really clean because points are described by many words
m = BetaAdicSet(x^5-x^3-2*x^2-1, [0,1])
m.plot()
m.critical_exponent()
# A beta-adic set
# the plot is not really clean because points are described by many words
m = BetaAdicSet(x^3-3*x^2-1, [0,1])
m.plot()
m.critical_exponent()
m = BetaAdicSet(1/(sqrt(2)+I), [0,1,2])
print(m)
m.plot()
m.critical_exponent()