# Expand a recursion relation

Hermite Polynoms have the following recursion relation: $$H_{n+1}(x) = 2x H_n(x) - 2n H_{n-1}(x),$$ which can be rearranged to be $$x H_n(x) = \frac{1}{2} H_{n+1}(x) - n H_{n-1}(x).$$

Is it possible, that in an expression like $$x^3 H_n(x)$$, $$x H_n(x)$$ is replaced recursively until no $$x H_n(x)$$ is left?

• Please, get into the habit of posting copyable code. – Henrik Schumacher Dec 12 '18 at 8:25
• As, for me, this is a more general question that would not esp. need this example. That is why I did not post special code. But this is probably my reduced understanding of the matter. I will give my best to do so in the future, thank you for the reminder. :) – pH13 - Yet another Philipp Dec 12 '18 at 9:09

Use ReplaceRepeated ( //. )

Format[H[n_]] := Subscript[H, n] // TraditionalForm

x^3 * H[n][x] //.
x^m_. * H[n_][x] :>
Expand[x^(m - 1) (H[n + 1][x]/2 - n*H[n - 1][x])] // Simplify


Yes, it is possible. The idea is a little different but I suppose equivalent: repeatedly replace according to the rule until x appears in the denominator.

rule = H[n_] :> 1/x (1/2 H[n + 1] - n H[n - 1]);
replace[expr_, rule_] := NestWhile[Simplify[# /. rule] &, expr, FreeQ[#, Power[x, -1]] &, 1, \[Infinity], -1]

replace[x^3 H[n], rule]

1/8 (-8 n (2 - 3 n + n^2) H[-3 + n] + 12 n^2 H[-1 + n] - 6 H[1 + n] - 6 n H[1 + n] + H[3 + n])