Problems in the documentation of the rising factorial

72 views
Skip to first unread message

Peter Luschny

unread,
Apr 28, 2016, 8:40:29 AM4/28/16
to sympy

I executed the examples in SymPy-Live but got different
outputs from what the docs say. For example for 

>>> rf(x, k).rewrite(ff)
gives  nothing  instead of: FallingFactorial(k + x - 1, k)

>>> rf(x, k).rewrite(binomial)
gives  (x)^(k)  instead of: binomial(k + x - 1, k)*factorial(k)

>>> rf(n, k).rewrite(factorial)
gives  (n)^(k)  instead of: factorial(k + n - 1)/factorial(n - 1)

Also for rf(x**3, 2) the output is different, not
Poly(x**6 + 3*x**5 + 3*x**4 + x**3, x, domain='ZZ')

Peter

Aaron Meurer

unread,
Apr 28, 2016, 2:37:09 PM4/28/16
to sy...@googlegroups.com
We still haven't updated SymPy Live to SymPy 1.0, so the output of
some examples may be different.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/d806b47b-6d46-4f44-ab9d-234ead67a02f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Peter Luschny

unread,
Apr 28, 2016, 5:28:22 PM4/28/16
to sympy
We still haven't updated SymPy Live to SymPy 1.0, so the output of
some examples may be different.

Thanks! Maybe I expressed myself misleading. Also the output in my 
yupyter notebook did not correspond to what is in the documentation.

I have difficulty to understand the output of the three calls
below which are taken from the doc-pages I cited.
-----------------------------------------------------
from sympy import rf, symbols, factorial, ff, binomial
from sympy.abc import x
n, k = symbols('n k', integer=True)

rf(x**3, 2)                 # ? x**3*(x**3 + 1)

rf(x, k).rewrite(binomial)  # ? RisingFactorial(x, k)

rf(n, k).rewrite(factorial) # ? RisingFactorial(n, k)
-----------------------------------------------------

Perhaps someone can enlighten me what to expect 
and to tell me if the output of SymPy 1.0 is correct?

Peter
 

Aaron Meurer

unread,
Apr 28, 2016, 6:17:46 PM4/28/16
to sy...@googlegroups.com
Maybe this bit from the docstring is causing confusion:

When x is a polynomial f of a single variable y of order >= 1,
rf(x,k) = f(y) * f(y+1) * ... * f(x+k-1) as described in
Peter Paule, "Greatest Factorial Factorization and Symbolic Summation",
Journal of Symbolic Computation, vol. 20, pp. 235-268, 1995.

So rf(x**3, 2) is x**3*(x + 1)**3.

I'm not sure why this definition is made. It seems like a bad one,
since there are two different ways to interpret rf(a, b) if a is a
polynomial. It looks like this was changed in
https://github.com/sympy/sympy/pull/8941.

For the other two, I get the same thing as the docstring in SymPy 1.0

>>> rf(x, k).rewrite(binomial)
binomial(k + x - 1, k)*factorial(k)
>>> rf(n, k).rewrite(factorial)
factorial(k + n - 1)/factorial(n - 1)

These seem mathematically correct.

It seems all three of these changed from SymPy 0.7.6 to SymPy 1.0.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/ad6fe0f9-d9b2-411a-ba3d-dc4b9378655a%40googlegroups.com.

Peter Luschny

unread,
Apr 29, 2016, 3:40:51 AM4/29/16
to sy...@googlegroups.com
> I'm not sure why this definition is made. It seems like a bad one,
> since there are two different ways to interpret rf(a, b) if a is a
> polynomial.  
> For the other two, I get the same thing as the docstring in SymPy 1.0
> These seem mathematically correct.

Thank you very much.

I agree with your comments, however I cannot reproduce the results
in my computing environment (SMC) similarly as SymPy Live cannot. 
I will have to investigate further.

Peter

Aaron Meurer

unread,
Apr 29, 2016, 12:13:59 PM4/29/16
to sy...@googlegroups.com
Double check that

import sympy
sympy.__version__

gives '1.0'.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/CAMMbGZYSTbN7q4_p5x8T2uPLZgONz9RJ58JqS%2BeS24dCdt1V-w%40mail.gmail.com.

Peter Luschny

unread,
Apr 29, 2016, 2:14:55 PM4/29/16
to sy...@googlegroups.com
> Double check that
> import sympy
> sympy.__version__
> gives '1.0'.

Yes, this was the issue. Solved and thanks.

Peter
Reply all
Reply to author
Forward
0 new messages