Skip to content

Instantly share code, notes, and snippets.

@cf
Created June 1, 2014 20:38
Show Gist options
  • Save cf/d27eea8e4aca845027bd to your computer and use it in GitHub Desktop.
Save cf/d27eea8e4aca845027bd to your computer and use it in GitHub Desktop.
Zeta function, ζ(x) for all real integers!
//My implementation of Zeta function, will extend to all complex numbers later
function GammaReal(n)
{
var s=1;
for(var i=2;i<n;i++)
{
s*=i;
}
return s;
}
function ZetaReal(r,n)
{
if(r>1)
{
var s=0;
for(var x=1;x<=n;x++)
{
s+=Math.pow(x,-r);
}
return s;
}else{
return 2*Math.pow(2*Math.PI,r-1)*Math.sin(r*Math.PI/2)*GammaReal(1-s)*ZetaReal(1-r,n);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment