ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 03 May 2016 08:38:32 -0500What is the bug ?http://ask.sagemath.org/question/33301/what-is-the-bug/I am writing this code in sage online worksheet given a tuple say $a=(a_1,a_2,...a_n)$ \phi be an permutation in S_n then \phi(a)= (a_\phi(1),...,a_\phi(n)) I want to count the number of permutation that fixes a The code is as follows
def Aut(tuple): c=1 for a in SymmetricGroup(len(tuple)): if a.action(tuple)== tuple : c=c+1Tue, 03 May 2016 00:31:12 -0500http://ask.sagemath.org/question/33301/what-is-the-bug/Answer by B r u n o for <p>I am writing this code in sage online worksheet given a tuple say $a=(a_1,a_2,...a_n)$ \phi be an permutation in S_n then \phi(a)= (a_\phi(1),...,a_\phi(n)) I want to count the number of permutation that fixes a The code is as follows</p>
<p>def Aut(tuple): c=1 for a in SymmetricGroup(len(tuple)): if a.action(tuple)== tuple : c=c+1</p>
http://ask.sagemath.org/question/33301/what-is-the-bug/?answer=33306#post-id-33306There is no method `action` for elements of the symmetric group. You should write `a(tuple)` instead of `a.action(tuple)`. And by the way, your function does not return anything, and I think `c` should be initialized to 0. Maybe:
def Aut(tuple):
c = 0
for a in SymmetricGroup(len(tuple)):
if a(tuple) == tuple:
c = c+1
return cTue, 03 May 2016 08:38:32 -0500http://ask.sagemath.org/question/33301/what-is-the-bug/?answer=33306#post-id-33306