Exponential sums make pretty pictures

Exponential sums are a specialized area of math that studies series with terms that are complex exponentials. Estimating such sums is delicate work. General estimation techniques are ham-fisted compared to what is possible with techniques specialized for these particular sums. Exponential sums are closely related to Fourier analysis and number theory.

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.

The exponential sum page at UNSW [link went away] suggests playing around with polynomials with dates in the denominator. If we take that suggestion with today’s date, we get the curve below:

f(n) = n/10 + n**2/7 + n**3/17

These are the partial sums of exp(2πi f(n)) where f(n) = n/10 + n²/7 + n³/17.

[Update: You can get an image each day for the current day’s date here.]

Here’s the code that produced the image.

    import matplotlib.pyplot as plt
    from numpy import array, pi, exp, log

    N = 12000
    def f(n):
        return n/10 + n**2/7 + n**3/17 

    z = array( [exp( 2*pi*1j*f(n) ) for n in range(3, N+3)] )
    z = z.cumsum()

    plt.plot(z.real, z.imag, color='#333399')

If we use logarithms, we get interesting spirals. Here f(n) = log(n)4.1.

f(n) = log(n)**4.1

And we can mix polynomials with logarithms. Here f(n) = log(n) + n²/100.

f(n) = log(n) + n**2/100

In this last image, I reduced the number of points from 12,000 to 1200. With a large number of points the spiral nature dominates and you don’t see the swirls along the spiral as clearly.


14 thoughts on “Exponential sums make pretty pictures

  1. I Made An exp Sum with the birthday of my first grandchild yesterday. (8 oct 2017). I put the Pic on a Card with the text : a suiting crown for Céline on her birthday.

  2. In that first example, the shapes remind me of Brusqueness figures. We a bit of work, I bet you could actually fit to a given silhouette.

  3. reducing the expression e^(2 * pi * i * f(n), I note that e^(pi * i) = -1
    so I reduce the expression to (-1)^(2 * f(n))
    2*f(n) = ( (n/mm) + (n^2/dd) + (n^3/yy)) yields a fraction
    thus, I have eliminated the i

  4. Here’s the code in Mathematica (it runs a bit slow)

    m = 2000;
    day = 21;
    month = 11;
    year = 17;
    f[n_] = n/day + n^2/month + n^3/year;
    g[x_] = Exp[2*Pi*I*f[x]];
    z = Array[g, m + 1, {3, m + 3}];
    z = Accumulate[z];
    p = ListPlot[{Re[#], Im[#]} & /@ z, PlotRange -> Automatic,
    ImagePadding -> 40, AspectRatio -> 1,
    FrameLabel -> {{Im, None}, {Re, “complex plane”}},
    PlotStyle -> Directive[Red, PointSize[.02]], Joined -> True];

  5. ok, I just answered my own question – the python code works fine under version 3.6 of python – I have a fedora workstation that has versions 2.7 and 3.6 and yup 2.6 was the default LOL

    -chuck rothauser

  6. I took the code John posted and added date input function with error checking :-)


    import matplotlib.pyplot as plt, time
    from numpy import array, pi, exp, log, e

    valid = False
    while not valid:
    date_str = input(“Enter Date(mm/dd/yy):”)
    time.strptime(date_str, “%m/%d/%y”)
    valid = True
    except ValueError:
    print(“Invalid Format For Date”)
    valid = False

    m = int(date_str[0:2])
    d = int(date_str[3:5])
    y = int(date_str[6:8])

    N = 12000

    def f(n):
    return n/m + n**2/d + n**3/y

    z = array( [exp( 2*pi*1j*f(n) ) for n in range(3, N+3)] )

    z = z.cumsum()

    plt.plot(z.real, z.imag, color=’#333399′)


  7. looks like 2018 will produce less interesting patterns compared to 2017.. 2017 is prime and 2018 is not!!

    correct me if i am wrong

  8. 2018 will produce simpler images since lcm(m, d, 18) is typically smaller than lcm(m, d, 17). The images are particularly simple now that m = 1, but some more complex images are coming.

Comments are closed.