Ask Your Question

Revision history [back]

There is another way to solve it in Sage, and we can completely do away with the use of Maxima here:

sage: from sage.functions.hypergeometric import closed_form
sage: [2*closed_form(hypergeometric([1-n,2-n],[2],-1)) for n in [1..20]]
[2, 2, 0, -2, 0, 4, 0, -10, 0, 28, 0, -84, 0, 264, 0, -858, 0, 2860, 0, -9724]

Maxima is still 2x faster with n in [1..2000] though.

There is another way to solve it in Sage, and we can completely do away with the use of Maxima here:

sage: from sage.functions.hypergeometric import closed_form
sage: [2*closed_form(hypergeometric([1-n,2-n],[2],-1)) for n in [1..20]]
[2, 2, 0, -2, 0, 4, 0, -10, 0, 28, 0, -84, 0, 264, 0, -858, 0, 2860, 0, -9724]

Maxima is still 2x faster with n in [1..2000] though.

See documentation at http://sagemath.org/doc/reference/functions/sage/functions/hypergeometric.html