I tried to define a simple rule defining how λ acts on ψ[n]
:
myrule1 = λ ψ[n_] -> α[n + 1] ψ[n + 1];
The result I get is correct provided there's just one λ on the RHS of ψ[n]
. For instance:
λ^2 ψ[n] //. myrule1
isn't computed at all. On the other hand, if I do it step by step:
λ α[1 + n] ψ[1 + n] /. myrule1
I get the correct result. I tried to define a new rule:
myrule2 = λ^m_ ψ[n_] -> α[n + 1] λ^(m - 1) ψ[n + 1];
but it doesn't work. Since the recursive method seemed to work, I created a function which multiplies ψ[m]
by λ n
times:
timesλ[n_] := Nest[Times[λ, #] /. myrule1 &, ψ[m], n] &
But this is a very crude way of solving this problem.
Do you have any other ideas?
Answer
If you look at the full form versions of λ ψ[n]
and λ^k ψ[n]
λ ψ[n] // FullForm
Times[λ, ψ[n]]
λ^k ψ[n] // FullForm
Times[Power[λ, k],ψ[n]]
you see that the second expression can't match your rule because it contains Power
. Therefore, as Daniel Lichtblau suggests, you need to have two rules.
rules = {λ ψ[n_] -> α[1 + n] ψ[1 + n],
λ^j_ ψ[n_] -> Product[α[s], {s, n + 1, n + j}] ψ[j + n]};
Now you can get both
λ ψ[n] /. rules
α[1 + n] ψ[1 + n]
and
λ^k ψ[n] /. rules
Product[α[s], {s, n + 1, n + k}] ψ[k + n]
Comments
Post a Comment