2019-08-30 13:05:52 -0500 commented answer How did simplify_full() manipulate this expression? Right. As the expression obtained by writing "(LHS(n,k)-RHS(n,k)).simplify_factorial()" is quite horrible, I suspect that Sage will not be able to give me any good insight into how to prove this equality. 2019-08-30 10:48:04 -0500 asked a question How did simplify_full() manipulate this expression? This is sort of a follow up to a previous question of mine: https://ask.sagemath.org/question/475... I wanted to prove a certain combinatorial equality. Now, to prove this identity in Sage, I can define the two function $\text{LHS}(n,k)$ and $\text{RHS}(n,k)$ representing the left- and righthand side and make sure that $\text{LHS}(n,k)-\text{RHS}(n,k)=0$ with the following code (actually the code provides a proof of a slightly more general identity, which holds for other values of $n, k$ as well.): var('n k') def LHS(n,k): return n/2*( (n/2+1-k)/(n/2+1)*((n/2+1)/(k/2)*binomial(n/2-3,k-4)*2**(n/2-k+1)*1/(k/2-1)*binomial(k-4,k/2-2))+ 2*(k/2+1)/(n/2+1)*((n/2+1)/(k/2+1)*binomial(n/2-3,k-2)*2**(n/2-k-1)*1/(k/2)*binomial(k-2,k/2-1))) def RHS(n,k): return (n/k)*(2**(n/2-k))*binomial(n/2-2,k-2)*binomial(k-2,k/2-1) (LHS(n,k)-RHS(n,k)).simplify_full()  This outputs 0  which is what I want but I would like to prove this identity with pen-and-paper and this seems to be a bit tricky. I wonder if there is a way to see how exactly simplify_full() were able simplify the expressions? 2019-08-20 16:38:35 -0500 commented answer Checking identity of two combinatorial expressions Thank you for your answer. I am still interested in the second question but if I get no other replies, I will accept your answer. 2019-08-20 16:36:07 -0500 commented answer Checking identity of two combinatorial expressions I am currently using 8.3, using the notebook if that is of any relevance. 2019-08-20 15:42:42 -0500 asked a question Checking identity of two combinatorial expressions I have a reason to believe that a certain combinatorial identity holds for even integers $n, k$ that satisfies $2 \leq k \leq n/2$ and $n\geq 4$. To test it in Sage, I denote the expression on the right- and lefthandside as the functions RHS$(n,k)$ and LHS$(n,k)$ respectively and check if they agree for a variety of values $n$ and $k$. def t(n,k): sum=0 for i in range(n-2*k+1): sum+=binomial(n-2*k,i) return n/k*sum*binomial(n-4,2*k-4)*catalan_number(k-2) def LHS(n,k): return n/2*((n/2+1-k)/(n/2+1)*t(n/2+1,k/2)+2*(k/2+1)/(n/2+1)*t(n/2+1,k/2+1)) def RHS(n,k): return (n/k)*(2**(n/2-k))*binomial(n/2-2,k-2)*binomial(k-2,k/2-1)  But when run the following code for n in range(6,12,2): for k in range(2,floor(n/2)+1,2): print("n="+str(n)+", k="+str(k)) print(bool(LHS(n,k)==RHS(n,k)))  I get the output n=6, k=2 True n=8, k=2 True n=8, k=4 True n=10, k=2 True n=10, k=4 False  which would indicate that the identity does not hold for $n=10$, $k=4$. However, when I write print(bool(LHS(10,4)==RHS(10,4)))  I get the output TRUE (I also double checked this by hand, and both sides agree and are equal to $30$ in this case). Why does the code in the double loop yield the wrong answer? EDIT: answered by rburing Is there a better way to check equalities similar to this in Sage? 2019-04-13 17:01:48 -0500 received badge ● Nice Question (source) 2019-04-13 17:01:34 -0500 received badge ● Nice Answer (source) 2019-04-11 09:03:45 -0500 received badge ● Self-Learner (source) 2019-04-11 09:03:45 -0500 received badge ● Teacher (source) 2019-04-11 08:42:31 -0500 commented answer Setting t=0 in a non-symmetric E-Macdonald polynomial Big thanks for this very pedagogical answer! 2019-04-11 08:33:37 -0500 answered a question Constructing all NE-lattice paths from $(0,0)$ to $(m,n)$ I fixed this myself but in case anyone is interested I will leave this as an answer. I decided to use the kbits from this thread to generate all binary strings of length $n$ with $m$ ones. Such strings are in a natural bijection with $NE$-lattice paths from $(0,0)$ to $(n,m)$. After that, I can get the heights of all the paths by writing Paths = WordPaths('01', steps=[(1,-1),(1,1)]) for b in kbits(m+n,m): print(Paths(b).ymax())  Note: Sage has a "height" function on words, but this is not what I am looking for. In the definition of height that I am using, the height of an $NE$-path is geometrically the biggest distance that the path is away from the main diagonal. 2019-04-11 02:56:49 -0500 asked a question Setting t=0 in a non-symmetric E-Macdonald polynomial Suppose I have a non-symmetric E-Macdonald polynomial indexed by, say, $\mu=(0,1,1)$. Then I can write from sage.combinat.sf.ns_macdonald import E E([0,1,1])  and I get a polynomial in three variables and with coefficients in $\mathbb{Q}(q,t)$: ((-t + 1)/(-q*t + 1))*x0*x1 + ((-t + 1)/(-q*t + 1))*x0*x2 + x1*x2  However, I am confused about how I can work with this polynomial. For my purposes, I would like to study the specialization $t=0$. It would be really neat if there were some way to get write something like Epoly(x_0,x_1,x_2,q,t) =...  so I could easily specialize variables as I go along. 2019-04-11 01:50:27 -0500 asked a question Constructing all NE-lattice paths from $(0,0)$ to $(m,n)$ If I consider only Dyck Paths, I can do write something like this: DWS=DyckWords(3).list() for D in DWS: print(D.height())  to obtain the height of all Dyck paths of length $3$. However, I would like to do the same thing but using $NE$-lattice paths from $(0,0)$ to $(m,n)$. Is there an easy way to do this in Sage? 2019-03-23 09:35:36 -0500 received badge ● Nice Question (source) 2019-03-23 06:26:52 -0500 asked a question Evaluating polynomials in Z[x] at roots of unity. Suppose that I have a polynomial $p(x)$ with integer coeffcients, then I can easily evaluate this at some integer to get an exact answer. That is, I can write something like sage: p=1+x+2*x^2+x^3+x^4 sage: p(2) 35  But If I instead want to evaluate this polynomial at a root of unity (I take $w$ to be a primitive $5$:th root of unity in the example below but any root of unity would do), then I may write say sage: w = e^(2*pi*i/5) sage: p(w) 1/256*(sqrt(5) + I*sqrt(2*sqrt(5) + 10) - 1)^4 + 1/64*(sqrt(5) + I*sqrt(2*sqrt(5) + 10) - 1)^3 + 1/8*(sqrt(5) + I*sqrt(2*sqrt(5) + 10) - 1)^2 + 1/4*sqrt(5) + 1/4*I*sqrt(2*sqrt(5) + 10) + 3/4  Which is a correct answer but written in a very complicated form. Alternatively, I can write sage: K. = CyclotomicField(5) sage: w=CC(z) sage: p(w) -0.809016994374947 + 0.587785252292473*I  which is an approximation of the correct answers. In the above case, we actually have $p(w)=w^2$ and I am wondering if there is an easy way to always obtain such an answer. For a general $p(x)$ with integer coefficients and $w$ that is a primitive $n$:th root of unity, we can write $p(w)$ on the form $$a_0+a_1 w + a_2 w^2 + \dots +a_{n-1} w^{n-1}$$ where the $a_i$:s are integers. Is there a good way to get the $p(w)$ on this form in Sage? 2019-03-19 10:36:27 -0500 commented question Major index of skew-SYT Added the definition of major index. 2019-03-19 07:56:58 -0500 received badge ● Organizer (source) 2019-03-19 07:33:16 -0500 received badge ● Editor (source) 2019-03-19 07:29:57 -0500 asked a question Major index of skew-SYT For a standard Young tableaux (SYT), I can compute the major index as follows: T = Tableau([[1,2,3],[4,5]]) T.major_index()  Is there a way to compute the major index of a skew-SYT currently? Something like: S = SkewTableaux().from_expr([[1,1],[,[3,4],[1,2]]]) S.major_index()  At the moment, it seems major_index() is not defined for the SkewTableau-class. EDIT: The major index of a (skew) standard Young tableau $T$, denoted $\mathrm{maj}(T)$, is defined as follows. A descent of $T$ is an entry $i$ such that $i+1$ appears strictly below $i$ in $T$. Define $\mathrm{maj}(T)$ as the sum of all descents of $T$. For example, the major index of the skew standard Young tableau above is $2+4=6$. FindStat has a definition, although they only define it for non-skew tableau. But the definition extends trivially to skew-shapes as well. 2019-03-12 05:26:15 -0500 commented answer Obtaining a poset from Posets(n) This partially solved my issues. But I would, if possible, like to use the major_index-function on the posets of Poset(n). So I would like to write something like P = Posets(3) Q = next(iter(P)) major_index(Q) but this gives me a similar error. 2019-03-10 08:53:21 -0500 asked a question Obtaining a poset from Posets(n) I have defined function that takes a poset $P$ as input and outputs the major index generating polynomial over all linear extensions of $P$. Here, the major index of a certain linear extension of $P$ is given by the major index of the corresponding permutation, see e.g. http://mathworld.wolfram.com/LinearEx... for an example of this correspondence. def major_index(pos): poly = 0 lst = pos.linear_extensions() for le in lst: perm = Permutation(x.element for x in le) maj = perm.major_index() poly += x^maj return poly  If I write, for example P = Poset(([1,2,3,4], [[1,3],[1,4],[2,3]]), linear_extension=True, facade=False) major_index(P)  Then I get x^4 + x^3 + x^2 + x + 1  which is the correct output. I would like to use Posets(n) to generate all posets (up to isomorphism) with $n$ vertices. However, when I write lst = Posets(3) P = lst major_index(P)  I get the error: Traceback (click to the left of this block for traceback) ... AttributeError: 'sage.rings.integer.Integer' object has no attribute 'element'  Clearly the error is due to the line perm = Permutation(x.element for x in le)  But I don't understand how Posets(n) works and why I cannot just write lst to obtain a poset. 2019-03-10 04:53:44 -0500 received badge ● Supporter (source) 2019-03-06 09:09:36 -0500 received badge ● Student (source) 2019-03-05 15:50:13 -0500 received badge ● Scholar (source) 2019-03-05 11:13:27 -0500 asked a question Obtaining integers from a linear extension of a poset. I'm quite new to Sage so this might be a very easy question. Suppose that I have defined a linear extension of a poset in Sage like this: P = Poset(([1,2,3,4], [[1,3],[1,4],[2,3]]), linear_extension=True, facade=False) p = P.linear_extension([1,4,2,3])  Is there a way for me to make this linear extension into a permutation? That is, I would like to obtain the permutation [1,4,2,3] from p.