I want to obtain the algebraic values of, for example, Hermite polynomials using SciPy but in a recursive manner.

Using Maple, for example, these can be defined as

for n from 1 to 6 do
    H(n_1,x):= 2*x*H(n,x) - 2*n*H(n-1,x);
    print( simplify(%) );
end do:

I can find no way in SciyPy to do this algebraically. Please can you help?


closed as off-topic by Kirill, Brian Borchers, GertVdE, nicoguaro Dec 11 '18 at 0:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Welcome to Computational Science StackExchange. The questions which are best ask here generally deal with wider topics in scientific computation, rather than single issues with particular packages, which may be more appropriately dealt with elsewhere. In this case, is it possible you've confused scipy and sympy, since the latter package actually dealt with symbolic mathematics. $\endgroup$ – origimbo Dec 10 '18 at 11:47
  • 1
    $\begingroup$ I agree with origimbo. I want to add that you can very easily get the coefficients of $H$ using just NumPy's polynomial package (docs.scipy.org/doc/numpy-1.13.0/reference/generated/…) by directly encoding the recurrence in a very similar way, although it's not symbolic. $\endgroup$ – Kirill Dec 10 '18 at 11:54
  • 1
    $\begingroup$ Many thanks, yes it was my mistake, I should have written sympy. I understand how to get numerical answers but I wanted in general to know how to get algebraic terms for general recursion examples using hermites as an example. Please advise where I would be best to repost this question. $\endgroup$ – porphyrin Dec 10 '18 at 14:06
  • $\begingroup$ The easiest way would be to use hermite(n, x). Regarding the recursion, you can use def hermite_recur(n, x): if n == 0: return 1; elif n == 1: return 2*x; else: return 2*x*hermite_recur(n - 1, x) - 2*(n- 1)*hermite_recur(n - 2, x) $\endgroup$ – nicoguaro Dec 10 '18 at 16:53
  • $\begingroup$ @nicoguaro, many thanks for your answer, I hadn't realised that a function could be used this way with Sympy. $\endgroup$ – porphyrin Dec 11 '18 at 9:57

Browse other questions tagged or ask your own question.