Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168747
Image: ubuntu2004
Function to calculate classical Kloosterman sum $S(m,n,c)=\sum_{\substack{ d\text{(mod c)} \\ gcd(c,d)=1 }} e\left(\frac{m\overline{d}+nd}{c}\right)$
def klsum(m,n,c): sum=1 for d in range(1,c-1): if gcd(d,c) == 1: dinv=inverse_mod(d,c) z=m*dinv+n*d sum=sum+exp(2*pi * i * z / c) return sum
Example $S(2,1,5)$
CC(klsum(2,1,5))
-1.42705098312484 - 0.587785252292472*I