Skip to content

Instantly share code, notes, and snippets.

@mforets
Last active May 7, 2017 17:52
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 mforets/440b0a137cdb732e18e6a2ca78ccc3b1 to your computer and use it in GitHub Desktop.
Save mforets/440b0a137cdb732e18e6a2ca78ccc3b1 to your computer and use it in GitHub Desktop.
residue calculus: exploring (non-commercial) complex variable features available through SageMath
sage: z = SR.var('z', domain='complex')
sage: k = SR.var('k', domain='integer')
sage: giac('assume(k, integer)')  # for Giac PExpect interface
sage: from sympy import symbols, sympify
sage: from sympy import residue as residue_sympy
sage: f = 1/x*((x^2+1)/(2*x))**(2*k)
sage: f.residue(x==0)   # wrong
(1/2)^(2*k)
sage: residue_sympy(sympify(1/x*((x^2+1)/(2*x))**(2*k)), sympify(x), 0)  # wrong
0
sage: giac('residue(1/x*((x^2+1)/(2*x))**(2*k), x, 0)')  # unevaluated
...
TypeError: An error occurred running a Giac command:
INPUT:
sage2:=residue(1/x*((x^2+1)/(2*x))**(2*k), x, 0):;
OUTPUT:
"Non holomorphic function 1/x*exp(k*ln((x^2+1)*1/2/x))^2 at x=0 Error: Bad Argument Value"
sage: f(k=4)
1/256*(x^2 + 1)^8/x^9
sage: f(k=4).residue(x==0)
35/128
sage: f.residue(x==0).subs(k==4)
1/256
sage: res(k) = 1/2**(2*k)*binomial(2*k, k)
sage: res(k=4)
35/128

see also #15854

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment