Python implementation of Weierstrass Function.

Weierstrass Function
Weierstrass Function
# ? 2019 TheFlyingKeyboard and released under MIT License

from math import cos

from matplotlib import pyplot as plt
from matplotlib.ticker import FuncFormatter
from pylab import rcParams

step = 0.0001  # the smaller the more precise the plot is
a = 0.5
b = 15
n = 100

intervalBegin = 0
intervalEnd = 1

data = []

for x in range(int((1 / step) * abs(intervalEnd - intervalBegin))):
    output = 0

    for i in range(n):
        output += pow(a, i) * cos(pow(b, i) * i * x * step)


rcParams['figure.figsize'] = 16, 9


plt.gca().get_xaxis().set_major_formatter(FuncFormatter(lambda x, p: format(x * step, ',')))



Python Weierstrass Function
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. You can read more about it the Cookies&Privacy Policy Section Above. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this. You can read more about it the Cookies&Privacy Policy Section.