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.Tue, 03 Nov 2015 22:53:13 +0100What does Sage offer for expression manipulations?https://ask.sagemath.org/question/30394/what-does-sage-offer-for-expression-manipulations/I heard that advanced expression manipulation isn't Sage's strong side. But are there simple conversions like
convert(expr, X) where X is in {factorial, binomial, Gamma, hypergeom, partfrac, etc.. }?
For example how to convert (n!/k!)*binomial(k,n-k) to factorials? With Maple this would look like:
convert( (n!/k!)*binomial(k,n-k), factorial);
Mon, 02 Nov 2015 06:07:04 +0100https://ask.sagemath.org/question/30394/what-does-sage-offer-for-expression-manipulations/Answer by tmonteil for <p>I heard that advanced expression manipulation isn't Sage's strong side. But are there simple conversions like
convert(expr, X) where X is in {factorial, binomial, Gamma, hypergeom, partfrac, etc.. }?</p>
<p>For example how to convert (n!/k!)*binomial(k,n-k) to factorials? With Maple this would look like:</p>
<pre><code>convert( (n!/k!)*binomial(k,n-k), factorial);
</code></pre>
https://ask.sagemath.org/question/30394/what-does-sage-offer-for-expression-manipulations/?answer=30398#post-id-30398You can try to simplify your expression as follows:
sage: var('k,n')
(k, n)
sage: expr = n.factorial()/k.factorial()*binomial(k,n-k)
sage: expr.factorial_simplify()
factorial(n)/(factorial(2*k - n)*factorial(-k + n))
Mon, 02 Nov 2015 10:39:39 +0100https://ask.sagemath.org/question/30394/what-does-sage-offer-for-expression-manipulations/?answer=30398#post-id-30398Comment by Peter Luschny for <p>You can try to simplify your expression as follows:</p>
<pre><code>sage: var('k,n')
(k, n)
sage: expr = n.factorial()/k.factorial()*binomial(k,n-k)
sage: expr.factorial_simplify()
factorial(n)/(factorial(2*k - n)*factorial(-k + n))
</code></pre>
https://ask.sagemath.org/question/30394/what-does-sage-offer-for-expression-manipulations/?comment=30441#post-id-30441Thanks. See my follow-up question 30440: What guarantees simplify?Tue, 03 Nov 2015 22:53:13 +0100https://ask.sagemath.org/question/30394/what-does-sage-offer-for-expression-manipulations/?comment=30441#post-id-30441