Groups
Groups
Sign in
Groups
Groups
sympy
Conversations
About
Send feedback
Help
subs in a sum
21 views
Skip to first unread message
Thomas Ligon
unread,
Oct 8, 2020, 3:30:44 PM
10/8/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sympy
Here is a code snippet (for test purposes):
from sympy import symbols, I, oo, Sum, exp
a, s, t, j = symbols('a s t j')
ex = Sum(a*exp((2*s + 1)*I*t), (s, -oo, oo))
print(ex)
ex = ex.subs(s, j)
print(ex)
The subs statement has no effect. Is there another way to do this?
Aaron Meurer
unread,
Oct 8, 2020, 3:33:57 PM
10/8/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sympy
subs() doesn't replace s because it is a bound variable. You can use
replace or xreplace to do it.
>>> Sum(a*exp((2*s + 1)*I*t), (s, -oo, oo)).xreplace({s: j})
Sum(a*exp(I*t*(2*j + 1)), (j, -oo, oo))
Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
sympy+un...@googlegroups.com
.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/57c9522d-7e3b-42be-88cb-1834a3d49efdn%40googlegroups.com
.
Thomas Ligon
unread,
Oct 8, 2020, 4:03:45 PM
10/8/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sympy
Thanks! I tried both replace and xreplace (to learn more) and they both worked for me, so I chose replace, since it looks simpler.
Reply all
Reply to author
Forward
0 new messages