1
$\begingroup$

I have a function as follows $$ R_{nl}(r)=r^l e^{-\frac{\mu r}{n}}\sum_{j=0}^{n-l-1}b_j r^j \tag{1} $$ where $$ b_{j+1}=\frac{2\mu}{n}\frac{j+l+1-n}{(j+1)(j+2l+2)}b_j \tag{2} $$ and $b_0=2\mu^{3/2}$ and $\mu=1$.

Now I want to write a code for calculating $R_{nl}(r)$. So I tried this

rvals = RecurrenceTable[{b[j + 1] == (2 \[Mu])/n ( j + l + 1 - n)/((j + 1) (j + 2 l + 2)) b[j], b[0] == 2 \[Mu]^(3/2)}, b, {j, 0, n - 1}];
rvals2 = PrependTo[rvals, 2 \[Mu]^(3/2)];
rfun[n_, l_, r_] :=r^l Exp[-\[Mu] r/n] Sum[rvals[[j]] r^j, {j, 0, n - l - 1}]

but when I try for example

rfun[2, 1, r]

it doesn't give me the answer. It seems that the recurrence table needs to specify the initial values for $n$ and $l$, but I want to use rfun[n, l, r] as a function in the next steps. Also I had tired

RSolve[{b[j + 1] == (2 \[Mu])/n (j + l + 1 - n)/((j + 1) (j + 2 l + 2)) b[j], 
  b[1] == 2 \[Mu]^(3/2)}, b[j], j]

for recursion relation but this does not yield my desire result too. Any idea?

$\endgroup$

1 Answer 1

4
$\begingroup$
Clear["Global`*"]

Using RSolveValue to find the closed-form expression for b

b[j_, l_, n_, μ_ : 1] = 
 RSolveValue[{b[
      j + 1] == (2 μ)/n (j + l + 1 - n)/((j + 1) (j + 2 l + 2)) b[j], 
    b[0] == 2 μ^(3/2)}, b[j], j] // FullSimplify


(* (2^(1 + j) μ^(3/2) (μ/n)^j Gamma[2 + 2 l] Gamma[1 + j + l - n])/(
Gamma[1 + j] Gamma[2 + j + 2 l] Gamma[1 + l - n]) *)

rfun[n_, l_, r_, μ_ : 1] = 
 r^l Exp[-μ r/n] Sum[b[j, l, n, μ] r^j, {j, 0, n - l - 1}]

(* 2 E^(-((r μ)/n)) r^l μ^(3/2)
  Hypergeometric1F1[1 + l - n, 2 + 2 l, (2 r μ)/n] *)

rfun[2, 1, r]

(* 2 E^(-r/2) r *)

Plot[rfun[2, 1, r], {r, 0, 15}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks a lot man. It works. just one thing: why you entered $\mu$ as an argument of function? I want to specify it in the beginning my code as an input. Can I pull it out from arguments? $\endgroup$
    – Wisdom
    Aug 11, 2021 at 16:28
  • 1
    $\begingroup$ It is set to default to 1 if not entered as an argument. If you prefer you can define it at the top and eliminate it from the LHS of definitions. $\endgroup$
    – Bob Hanlon
    Aug 11, 2021 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.