Skip to content

Instantly share code, notes, and snippets.

@jasongrout
Created June 6, 2011 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongrout/1010165 to your computer and use it in GitHub Desktop.
Save jasongrout/1010165 to your computer and use it in GitHub Desktop.
Efficient sum that doesn't try to simplify in Sage
def fsum(x,a):
g(x) = 1/2
list_of_terms=[2*(((-1)^n-1)/(n*pi)^2*cos(n*pi*x)-(-1)^n/(n*pi)*sin(n*pi*x)) for n in [1..a]]
g += sum(list_of_terms)
return g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment