So, I was playing with Fourier series just for fun and got a weird idea.

I'm sure that someone have think of this series before

$f(x) = \displaystyle\sum_{n=1}^{\infty} {{\frac {(-1)^n} {p_n}}\sin(p_nx)}$

Where $p_n$ is the n-th prime number

This is the plot involving first 20 prime numbers using desmos.

enter image description here

I have 2 questions regarding this series.
  1. Is this plot smooth and/or analytics in the limit?
  2. Does anyone know how to plot this function?

I try using python, but couldn't really figure out how to do it.

  • $\begingroup$ I think that what you plotted is $$f(x) = \displaystyle\sum_{n=1}^{\infty} {{\frac {(-1)^{n+1}} {p_n}}\sin(p_nx)}$$ Why not to rescale the plot to make it nicer (say $y$ values between $-1.2$ and $1.2$). ?$ Interesting problem $\endgroup$ Aug 5, 2022 at 7:36
  • $\begingroup$ I tried with the first $10,000$ first prime numbers. It does not change much (as we can expect). $\endgroup$ Aug 5, 2022 at 7:55
  • $\begingroup$ What could be interesting would be remove the noise from the signal. Have a look at medium.com/analytics-vidhya/… $\endgroup$ Aug 5, 2022 at 8:56

1 Answer 1


For the plot, use the following input in Wolfram Alpha

Plot[Sum[((-1)^(1 + n)*Sin[x*Prime[n]])/Prime[n], {n, 1, p}],{x,-2Pi,2Pi}]

Give $p$ the value you want

  • $\begingroup$ Thank you for the code. After seeing more terms, I even more curious whether the function is analytics, or maybe its a fractal $\endgroup$
    – Tensor
    Aug 5, 2022 at 10:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .