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.Wed, 04 Nov 2015 03:54:56 +0100What guarantees simplify()?https://ask.sagemath.org/question/30440/what-guarantees-simplify/ How to convert (n!/k!)*binomial(k,n-k) to factorials? From an answer of tmonteil in question 30394:
var('k,n')
expr = n.factorial()/k.factorial()*binomial(k,n-k)
expr.factorial_simplify()
factorial(n)/(factorial(2*k - n)*factorial(-k + n))
The new question is: what is the contract of simplify()
(or factorial_simplify())?
I think a simplification is only useful if it returns
an equivalent expression. Is this is guaranteed?
In our example: Take n=1 and k=0. expr is 0 in this case
but expr.factorial_simplify() is not defined (or gives an
ValueError if executed) because factorial(2*k-n) = factorial(-1).
So my question might be rephrased: Is this an accidental
bug or a systematic unreliability which renders simplify()
essentially useless?
Peter
Tue, 03 Nov 2015 22:51:24 +0100https://ask.sagemath.org/question/30440/what-guarantees-simplify/Comment by kcrisman for <p>How to convert (n!/k!)*binomial(k,n-k) to factorials? From an answer of tmonteil in question 30394:</p>
<pre><code>var('k,n')
expr = n.factorial()/k.factorial()*binomial(k,n-k)
expr.factorial_simplify()
factorial(n)/(factorial(2*k - n)*factorial(-k + n))
</code></pre>
<p>The new question is: what is the contract of simplify()
(or factorial_simplify())? </p>
<p>I think a simplification is only useful if it returns
an equivalent expression. Is this is guaranteed? </p>
<p>In our example: Take n=1 and k=0. expr is 0 in this case
but expr.factorial_simplify() is not defined (or gives an
ValueError if executed) because factorial(2*k-n) = factorial(-1).</p>
<p>So my question might be rephrased: Is this an accidental
bug or a systematic unreliability which renders simplify()
essentially useless?</p>
<p>Peter</p>
https://ask.sagemath.org/question/30440/what-guarantees-simplify/?comment=30446#post-id-30446Simplification is simpler and hence presumably not always exactly the same. In fact, even `x/x` isn't really `1`. I think one should expect measure zero differences in such situations.Wed, 04 Nov 2015 03:54:56 +0100https://ask.sagemath.org/question/30440/what-guarantees-simplify/?comment=30446#post-id-30446