Skip to content

Instantly share code, notes, and snippets.

@laserbat
Created January 21, 2012 15:18
Show Gist options
  • Save laserbat/1653044 to your computer and use it in GitHub Desktop.
Save laserbat/1653044 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import math
def func(x, prec):
if (x + 0.5) == round(x + 0.5):
return x - 0.5
y = 0
for i in range(1, prec + 2):
y += ((-1)**i * math.sin(2 * i * x * math.pi)) / i
return x + (y / math.pi).real
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment