Need advice on approximating the sum of a trigonomitric series which (I think) has no analytical solution

complex-analysisnumerical methodssequences-and-seriestaylor expansiontrigonometric series

I've encountered a maths problem in a programming project I'm working on. I've tried a lot of things already, and I'm feeling very swamped with maths that is way above my head.

I need to find:

$$f_N(x) = \sum_{n=1}^N cos(n^2x)$$

Now I've discovered I can use de Moivre's theorum and express this as the real part of an exponential series

$$Re\{ \sum_{n=1}^N e^{in^2x} \}$$

After some investigation I don't believe there is an analytical solution for this, so I'm not sure it's useful.

Numerical appromimations are better than the brute force approach I'm currently using as speed is far more importent than accuracy for my use case.

I believe what I'm looking for is the Taylor expansion of the first equation – however I have no idea how to approach finding the Taylor expansion of a sum to n. Maybe it's not possible? Googleing hasn't helped me here, searching "Taylor expansion of a finite series" just comes up with results for "Taylor series".

I think that maybe what I can do is find the derivatives of $f_N(x)$ use those as the terms in the Taylor series. I have a few questions:

  • Am I correct in saying that the second equation doesn't have an analytical solution?
  • Is using the Taylor expansion by finding the derivatives of the series the correct approach? (UPDATE: Just found this, which is for a polynomial rather than a trigonometric function, but leads me to believe that this method is valid. UPDATE 2: not possible, coefficients in the taylor expansion are themselves a series)
  • If so, does anyone have any examples of a Taylor expansion of a series that I could look at?
  • If not, what alternatives should I be looking at for finding a numerical approximation?

UPDATE: I should add that x is small, $0 < n^2x < \pi$ which should make
approximations easier

Thanks!

PS: I'm not a mathematician (which I'm sure is obvious!) and it has been a long time since I was at uni – would really appreciate answers in the form a comp-sci undergraduate could understand (to the extent to which that is possible!)

Best Answer

It looks like:

$$\sum_{n=1}^N \cos(n^2x)= \text{Re}\sum_{n=1}^N e^{i x n^2} $$

Now a difference:

$$\sum_{n=0}^b a_n=\sum_{n=0}^\infty a_n-\sum_{n=b}^\infty a_n\implies \text{Re}\sum_{n=1}^N e^{i x n^2} = \text{Re}\sum_{n=1}^\infty e^{i x n^2} - \text{Re}\sum_{n=N}^\infty e^{i x n^2} $$

So the general idea is to:

$$\text{Re}\sum_{n=1}^\infty e^{i x n^2} - \text{Re}\sum_{n=N}^\infty e^{i x n^2}= \text{Re}\sum_{n=1}^\infty e^{i x n^2} - \text{Re}\sum_{n=0}^\infty e^{i x (n+N)^2} $$

Now use Jacobi theta functions

However, an infinite sum, by itself, may diverge

Please correct me and give me feedback!

Related Question