#
# PYTHON • MyCompiler
# BlancMange Curve
# https://[Log in to view URL]
# BlancMange Curve
#
# 2026 Julho Sex,31 — Agosto Seg, 3
# by
# j
#
import matplotlib.pyplot as plt
def s(x):
y = abs(x - round(x))
return y
def blanc(x,w,MAX):
f = 0.0
n = 0
while (n < MAX):
f += (w**n)*s(2**n * x )
n += 1
return f
def takagi(w,MAX):
plt.style.use('dark_background')
plt.figure(figsize=(7,7))
x = []
y = []
xmin = 0.00
xmax = 1.00
n = 100
delta = (xmax - xmin)/n
for i in range(n + 1):
z = xmin + i * delta
f = blanc(z, w, MAX)
x.append(z)
y.append(f)
plt.plot(x, y, linewidth=4, color = "white")
tit = 'Blancmange Curve | w = ' + str(w) + ' MAX = ' + str(MAX)
plt.axis('equal')
plt.title(tit)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.show()
takagi(1/2,7)
To embed this project on your website, copy the following code and paste it into your website's HTML: