Vectorizing a summation

On a separate note, this is a very inefficient way to sum a series like this. You are recomputing the binomial factor and powers like c[k]^p separately for each loop iteration, when in practice you can compute them much more efficiently using a recurrence relation from the previous term.

See e.g. Sinc function - and sinc neural networks - and function approximation for the former - #4 by stevengj

1 Like