import matplotlib.pyplot as plt from numpy import array,linspace,sqrt,sin from numpy.linalg import norm def fixedp(f,x0,tol=10e-5,maxiter=100): """ Fixed point algorithm """ e = 1 itr = 0 xp =  while(e > tol and itr < maxiter): x = f(x0) # fixed point equation e = norm(x0-x) # error at the current step x0 = x xp.append(x0) # save the solution of the current step itr = itr + 1 return x,xp f = lambda x : sqrt(x) x_start = .5 xf,xp = fixedp(f,x_start) x = linspace(0,2,1000) y = f(x) plt.plot(x,y,xp,f(xp),'bo', x_start,f(x_start),'ro',xf,f(xf),'go',x,x,'k') stringa = "Fixed Point: " + str(round(xf, 4))
Exponential sums are a specialized area of math that studies series with terms that are complex exponentials.
Exponential sums also make pretty pictures. If you make a scatter plot of the sequence of partial sums you can get surprising shapes. This is related to the trickiness of estimating such sums: the partial sums don’t simply monotonically converge to a limit. By the plot of an exponential sum we mean the sequence of partial sums, plotted in the complex plane, with successive points joined by straight line segments. That is, we start at the origin; draw a line interval corresponding to the first term of the sum; from the end of this interval draw another, corresponding to the second term of the sum; and so on.
Following this article, we playing around with polynomials with dates in the denominator. If we take that suggestion, with
and with today’s date, we get the curve below:
import matplotlib.pyplot as plt from numpy import array, pi, exp, log N = 20000 def f(n): return n/25 + n**2/11+ n**3/20 z = array( [exp( 2*pi*1j*f(n) ) for n in range(0, N)] ) z = z.cumsum() plt.plot(z.real, z.imag, color='#333399') plt.axes().set_aspect(1) plt.show()
An interesting picture is the exponential sum with
f(n)=(log n)4 and
N=5000. The graph was dubbed “the Loch Ness monster” by John Loxton in a 1981 article.