1
$\begingroup$

I use the code

fv = RecurrenceTable[{a[i] == 
     1/(i (i + 1)) (1/Sqrt[w] a[i - 1] + (2 i - 1 - e[i]) a[i - 2]), 
    a[2] == 1/6 (1/(2*w)+3 - e[i]), a[1] == 1/(2 Sqrt[w])}, a, {i, 3, 10}];

to evaluate the three-step recursion relation where

e[i_]:=e[i]=2i+1

after that I need to obtain the roots of fv, so I use

sol2 = N[Solve[fv[[1]] == 0, w]]

my main problem is that e must be calculated using max i, namely the code must calculate the value of e first, then must use i to calculate recursion relation, For example for i=3 , e becomes 7, then a[3] must be calculated that includes e[3] and a[2] and a1, where a[2] must be calculated using e[3] again not e[2], maybe some sort of a loop needed. I really don't know how to address this problem. Any idea?

The correct results for what I intend are:
i=3, w=0.05;
i=4, w=0.0182 and w=0.1900;
and so on.

You can see the original paper which has introduced the above formula and the results here. I have marked important formula. The results have been shown in the table.

$\endgroup$
  • $\begingroup$ I'm not entirely sure I understand the question - are you asking how to change your code such that a[i] is computed using e[i] everywhere, even for a[i-1] etc.? $\endgroup$ – Lukas Lang Oct 13 at 17:28
  • $\begingroup$ @LukasLang yes, I explained it in my example. $\endgroup$ – Wisdom Oct 13 at 18:16
  • $\begingroup$ @bbgodfrey sorry it was a mistyping, I corrected it $\endgroup$ – Wisdom Oct 13 at 19:02
  • $\begingroup$ Thanks a lot for your answer. Sorry I forgot to type a 3 in a[2] formula. I corrected it, however just first case (i=3) gives correct answer but other results are wrong, I checked my formula but there was no mistake. Do you think two different roots for i>3 cause the mistake? $\endgroup$ – Wisdom Oct 13 at 20:12
  • 1
    $\begingroup$ @Wisdom How did you obtain the values of w in the question for i = 4? Please show the equation you solved. $\endgroup$ – bbgodfrey Oct 13 at 22:00
2
$\begingroup$

Here is an example that doesn't use RecurrenceTable but rather simply defines recursive functions for this (note the addition of a second argument to a):

e[i_] := 2i+1
a[i_] := a[i, e[i]];

a[i_, e_] := 1/(i (i + 1)) (1/Sqrt[w] a[i - 1, e] + (2 i - 1 - e) a[i - 2, e]);
a[2, e_] := 1/6 (1/(2*w) + 3 - e);
a[1, e_] := 1/(2 Sqrt[w])

To create a similar list as you would get from RecurrenceTable:

fv = Table[a[i], {i, 3, 10}]
$\endgroup$
  • $\begingroup$ your code does't work and yields a e[3], e[4] and so on. $\endgroup$ – Wisdom Oct 14 at 12:22
  • $\begingroup$ @Wisdom edited to include your definition of e as well (without the memoisation) $\endgroup$ – Gerli Oct 14 at 12:23
  • $\begingroup$ Ohhhh Thank you soooo much, it returned my desire results exactly. $\endgroup$ – Wisdom Oct 14 at 12:30
1
$\begingroup$

With the clarification provided by the reference now given in the question, the desired solution is easily obtained.

a[1] := 1/(2 Sqrt[w]); 
a[2] := 1/6 (1/(2 w) + 3 - e); 
a[i_] := 1/(i (i + 1)) (1/Sqrt[w] a[i - 1] + (2 i - 1 - e) a[i - 2]);
Flatten[Table[NSolve[(a[i] /. e -> 2 i + 1) == 0, w], {i, 3, 10}], {{3}, {1}}][[1]] // Values

(* {{0.05}, 
    {0.190065, 0.0182686}, 
    {0.0404842, 0.0086731}, 
    {0.156634, 0.015429, 0.00478921}, 
    {0.0344873, 0.00753932, 0.00292085}, 
    {0.134788, 0.0134812, 0.00424987, 0.00191167}, 
    {0.0302949, 0.00671401, 0.0026321, 0.00131905},
    {0.119177, 0.012046, 0.00383985, 0.0017433, 0.000948279}} *)

The reciprocals of these values are precisely those given in the reference. Note that Flatten[. . ., {{3}, {1}}][[1]] merely eliminates unnecessary pairs of curly brackets.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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