2
$\begingroup$

This is probably very simple, but I just cannot find this anywhere online. I have the code

Y1[m_,n_,r_] := FullSimplify[RSolve[{A[m,n,r] == (-m-m*(r/n)*(n-m))*A[m-1,n,r] - m*(r/n)*(m-1)*(n-m+1)*A[m-2,n,r], A[0,n,r]==1, A[1,n,r]==-1-((r/n)*(n-1))}, A[m,n,r], {m,n,r}]]

I think it is clear what I am trying to do: I hope to get a function Y1 that solves this recurrence. If I run this line and then write something like

Y1[m, n, r]

I get

{{A[m,n,r]->(E^(-(n/r)) (r/n)^m Gamma[1+m] ((E^(n/r) r+n ExpIntegralE[n,-(n/r)]) Gamma[1+m-n]+n^2 (-(n/r))^m ExpIntegralE[-m+n,-(n/r)] Gamma[-n]))/(r Gamma[1-n])}}

This is not what I had hoped. I want Y1 to be my function, but now A is the function I want. However, I cannot just use A either, since it just seems to be some intermediate function and it is not defined.

How can I get the function in m,n,r that is the solution of my RSolve?

$\endgroup$
4
  • 1
    $\begingroup$ Try: Y1[m_, n_, r_] := A[m, n, r] /. FullSimplify[.... $\endgroup$ Apr 26, 2023 at 7:32
  • 1
    $\begingroup$ Thank you for your comment @DanielHuber. It sadly doesn't seem to work, but it almost does, so I might be doing something wrong or maybe my question wasn't clear. It seems if I execute the line you mention that Y1 is still 'in between brackets', if that makes sense. If I try for example Y1[2.01,2.01,1] then I am getting the error "RSolve::dsvar: 2.01` cannot be used as a variable." $\endgroup$ Apr 26, 2023 at 7:50
  • 1
    $\begingroup$ replace RSolve with RSolveValue? $\endgroup$
    – kglr
    Apr 26, 2023 at 8:49
  • 1
    $\begingroup$ .. and := with =? $\endgroup$
    – kglr
    Apr 26, 2023 at 8:56

1 Answer 1

5
$\begingroup$

To make my comment clear, here is the full code:

Y1[m_, n_, r_] = 
 A[m, n, r] /. 
  FullSimplify[
    RSolve[{A[m, n, r] == (-m - m*(r/n)*(n - m))*A[m - 1, n, r] - 
        m*(r/n)*(m - 1)*(n - m + 1)*A[m - 2, n, r], A[0, n, r] == 1, 
      A[1, n, r] == -1 - ((r/n)*(n - 1))}, 
     A[m, n, r], {m, n, r}]][[1]]

Then:

Y1[2.1, 2.1, 1]

2.10524 + 0.595942 I
$\endgroup$
2
  • 1
    $\begingroup$ Thank you! I think your original comment didn't work because it included := (just like i originally did) instead of = as @kglr pointed out as well $\endgroup$ Apr 26, 2023 at 9:11
  • 1
    $\begingroup$ Or for an alternate representation, Y1r[m_, n_, r_] = Y1[m, n, r] // FunctionExpand // Simplify $\endgroup$
    – Bob Hanlon
    Apr 26, 2023 at 17:35

Your Answer

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

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