ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 13 Feb 2021 21:40:36 +0100prove an identity for any integerhttps://ask.sagemath.org/question/55699/prove-an-identity-for-any-integer/Let $n$ be a positive integer and $m = (m_1, \ldots, m_n)$ an $n$-dimensional vector of real numbers.
Let $g$ be a real number.
I want to prove, for any $n$ and $m$, an equality of the form
$$ \sum_{i=1}^n f_i (m,g) = 0 $$
where the function $f_i$ is a rational function of $m$ and $g$.
Of course it's easy to check this by substituting finite values of $n$, but is there a way in Sage to prove it for any integer?rue82Sat, 13 Feb 2021 21:40:36 +0100https://ask.sagemath.org/question/55699/How did simplify_full() manipulate this expression?https://ask.sagemath.org/question/47674/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/47535/checking-identity-of-two-combinatorial-expressions/
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?joakim_uhlinFri, 30 Aug 2019 17:48:04 +0200https://ask.sagemath.org/question/47674/Checking identity of two combinatorial expressionshttps://ask.sagemath.org/question/47535/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).
1. Why does the code in the double loop yield the wrong answer? EDIT: answered by rburing
2. Is there a better way to check equalities similar to this in Sage?joakim_uhlinTue, 20 Aug 2019 22:42:42 +0200https://ask.sagemath.org/question/47535/