11

Let be given sequence $(u_n)$ satisfying: $$u_1 = 1, \quad u_{n+1} = u_n + 1 + \sqrt{u_n+3}, \forall n \geq 1.$$ I tried

ClearAll["Global`*"];
RSolve[{a[x, n + 1] == a[x, n]  + 1 +  Sqrt[ a[x, n] + 3], 
  a[x, 1] == 1}, a[x, n], n]

{{a[x, n] -> 6 - 6 n + n^2}, {a[x, n] -> -2 + 2 n + n^2}}

With the answer a[x, n] -> -2 + 2 n + n^2}. I tried

Table[-2 + 2 n + n^2, {n, 10}]

{1, 6, 13, 22, 33, 46, 61, 78, 97, 118}

By hand, I get $u_2 = 1 + 1 + \sqrt{4} = 4. $

I also tried

RSolve[{a[n + 1] == a[n] + 1 + Sqrt[a[n] + 3], a[1] == 1}, a[n], n]

and get the same answer.

Where is wrong in my code to find $u_n$?

minhthien_2016
  • 3,347
  • 14
  • 22
  • 1
    Your recursion relation can be transformed into the difference equation, which can be written as an ordinary differential equation, which has an analytic solution. This allows to obtain an accurate asymptotic. Maybe it hints that your recursion can be solved as well. – yarchik Nov 25 '23 at 09:52
  • 2
    It seems have a bug with RSolve. Another question https://mathematica.stackexchange.com/questions/293296/how-can-i-find-some-first-terms-of-a-sequence – minhthien_2016 Nov 26 '23 at 03:47

2 Answers2

3

It could be that there is a closed form solution. Following considerations demonstrate that it cannot be simple. Important message is that $u_n$, besides quadratic grows demonstrated in the other answer, has sub-leading logarithmic terms.

Let us first reformulate the recurrence using the $t_n^2=u_n+3$ substitution. We get $$ t_{n+1}^2=t_n^2+t_n+1,\\ t_1=2. $$ MA cannot solve this recursion.

However, it can be reformulated introducing a difference $y_n=t_{n+1}-t_n$. We get $$ y_n(y_n+2t_n)=t_n+1. $$

This can approximately be written as an ordinary differential equation (ODE) $$ x'(t)\big(x'(t)+t\big)=t+1,\\ x(1)=2. $$

This can be solved analytically with MA

DSolve[{y'[x] (y'[x] + 2 y[x]) == y[x] + 1, y[1] == 2}, y[x], x]

we select the growing solution and define

f[x_] := 
 InverseFunction[-2 Log[-#1 + Sqrt[1 + #1 + #1^2]] + 
     3/2 Log[-1 - 2 #1 + 2 Sqrt[1 + #1 + #1^2]] + #1 + Sqrt[
     1 + #1 + #1^2] &][x + 1/2 (2 + 2 Sqrt[7] - 4 Log[-2 + Sqrt[7]] + 
      3 Log[-5 + 2 Sqrt[7]])]

Let us verify the accuracy.

i. Generate log-mesh for plotting purposes. Represent only 20 points in the range $[1, 10000]$

kmx = 20;
nmx = 100000;
p = Exp[Log[nmx]/kmx] // N
ni = Table[t = Round[p^(i - 1)]; t, {i, 1, kmx}] // DeleteDuplicates

ii. Generate the solution of the 2nd recursion.

a = {2};
Do[AppendTo[a, x = Last[a]; N[Sqrt[x^2 + x + 1]]], {n, nmx}]
an = Table[{i, a[[i]]}, {i, ni}]

iii. Generate the solution of the 1st recursion.

u = {1};
Do[AppendTo[u, x = Last[u]; N[x + 1 + Sqrt[x + 3]]], {n, nmx}]
un = Table[{i, u[[i]]}, {i, ni}]

iv. Plot 2nd recursion vs analytic solution

g1 = LogLogPlot[f[n], {n, 1, nmx}];
g2 = ListLogLogPlot[an, 
  PlotStyle -> Directive[PointSize[Medium], Orange]];
Show[{g1, g2}]

enter image description here

And here is the same graph with the polynomial asymptotic. enter image description here

v. Plot 1st recursion vs analytic solution

g3 = LogLogPlot[f[n]^2 - 3, {n, 1, nmx},PlotTheme -> "NeonColor"];
g4 = ListLogLogPlot[un, 
  PlotStyle -> Directive[PointSize[Medium], Blue]];
Show[{g3, g4}]

enter image description here

And here is the same graph with the polynomial asymptotic. enter image description here

Finally, in the case someone needs a practical formula working in the whole range. One can transform the original recursion into a differential equation with the solution

v[n_] := -2 + 2 ProductLog[-1, -3 E^(-(5/2) - n/2)] + 
  ProductLog[-1, -3 E^(-(5/2) - n/2)]^2

Using properties of the Lambert W function one can with high accuracy write

g[n_] := Log[3 E^(-(5/2) - n/2)] - Log[5/2 + n/2 - Log[3]] + 
  Log[5/2 + n/2 - Log[3]]/Log[3 E^(-(5/2) - n/2)] + (Log[5/2 + n/2 - Log[3]]*(Log[5/2 + n/2 - Log[3]] - 2))/(2* Log[3 E^(-(5/2) - n/2)]^2)

w[n_] := -2 + 2*g[n] + g[n]^2

This function has the following asymptotic form

wa[n_]:=1/4 (-3 + n (6 + n)) - (3 + n) Log[3] + Log[3]^2
yarchik
  • 18,202
  • 2
  • 28
  • 66
  • First, you obtain an approximate solution according to your "This can approximately be written as an ordinary differential equation (ODE)". Second, InverseFunction[-2 Log[-#1 + Sqrt[1 + #1 + #1^2]] + 3/2 Log[-1 - 2 #1 + 2 Sqrt[1 + #1 + #1^2]] + #1 + Sqrt[ 1 + #1 + #1^2] &][x + 1/2 (2 + 2 Sqrt[7] - 4 Log[-2 + Sqrt[7]] + 3 Log[-5 + 2 Sqrt[7]])] is neither a closed-form expression nor an analytic expression (see Wiki for the definitions). – user64494 Nov 25 '23 at 15:17
  • Third, can you kindly compare your result with u[n_]:=1/4*n^2-3 obtained by me? TIA. – user64494 Nov 25 '23 at 15:35
  • Table[{Log[f[n]^2 - 3], Log[1/4*n^2 - 3]}, {n, 10, 10010, 500}] // N results in {{3.89177, 3.09104}, {11.1196, 11.0825}, {12.4699, 12.4491}, {13.2682, 13.2534}, {13.837, 13.8255}, {14.2793, 14.2698}, {14.6412, 14.6331}, {14.9475, 14.9404}, {15.2131, 15.2068}, {15.4475, 15.4418}, {15.6573, 15.6521}, {15.8471, 15.8423}, {16.0205, 16.0161}, {16.18, 16.1759}, {16.3277, 16.3239}, {16.4653, 16.4617}, {16.594, 16.5906}, {16.7149, 16.7117}, {16.829, 16.8259}, {16.9368, 16.9339}, {17.0392, 17.0364}}. The difference decreases as n increases. – user64494 Nov 25 '23 at 15:59
  • Also g3 = LogLogPlot[f[n]^2 - 3, {n, 1, nmx}, PlotTheme -> "NeonColor"]; g4 = ListLogLogPlot[un, PlotStyle -> Directive[PointSize[Medium], Blue]]; g5 = LogLogPlot[1/4*n^2 - 3, {n, 1, nmx}, PlotTheme -> "BoldColor"]; Show[{g3, g4, g5}] shows the same lines. Compare InverseFunction[-2 Log[-#1 + Sqrt[1 + #1 + #1^2]] + 3/2 Log[-1 - 2 #1 + 2 Sqrt[1 + #1 + #1^2]] + #1 + Sqrt[ 1 + #1 + #1^2] &][x + 1/2 (2 + 2 Sqrt[7] - 4 Log[-2 + Sqrt[7]] + 3 Log[-5 + 2 Sqrt[7]])] witn 1/4x^2-3. Hope you feel the difference. – user64494 Nov 25 '23 at 16:20
  • Your termin "lowest order order asymptotic" is not exact. I find "polynomial asymptotic" more exact. I think the complicated approach used by you is a road to nowhere: nothing better than 1/4 n^2-3. – user64494 Nov 25 '23 at 16:39
  • One more approach: consider ODE DSolve[{u'[n] == Sqrt[u[n] + 3], u[1] == 1}, u[n], n], where the term 1 is omitted, instead of RE under consideration. Then {{u[n] -> 1/4 (-3 + 6 n + n^2)}}. – user64494 Nov 25 '23 at 18:11
  • Can you elaborate your claim "One can transform the original recursion into a differential equation with the solution", giving us details? I obtain by sol = DSolve[{u'[n] == 1 + Sqrt[u[n] + 3], u[1] == 1}, u[n], n] // FullSimplify the following result {{u[n] -> -2 + ProductLog[E^((3 - n)/2)] (2 + ProductLog[E^((3 - n)/2)])}} and a warning "Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information." Plot Plot[u[n] /. sol, {n, 1, 14}] clearly shows that sol is not correct. – user64494 Nov 26 '23 at 14:52
  • @user64494 I haven't put the solution because I obtained it partially by hand. I sketch the idea here. One starts with ODE that you wrote. It is convenient to reformulate it for the inverse function. Next, solve it (+ initial conditions) with MA. Finally, invert the solution paying attention to the branch of ProductLog. In fact, there is only one branch (-1) that yields a real solution. MA does not know the asymptotic expansion of the ProductLog for this branch. Therefore, one needs to do it by hand following https://en.wikipedia.org/wiki/Lambert_W_function#Asymptotic_expansions. – yarchik Nov 27 '23 at 13:53
  • I don't find your reply satisfactory. In particular, it's unclear to me why " It is convenient to reformulate it for the inverse function". – user64494 Nov 27 '23 at 15:25
  • @user64494 So that it can be integrated by the separation of variables. This is the standard method for the solution of first-order autonomous ordinary differential equations. You can ask an independent question, as why MA cannot properly solve it, and what are the workarounds. – yarchik Nov 27 '23 at 15:31
  • Thank you, this is a serious argument. Can you present the ODE you work with? TIA. BTW, Maple correctly solves {u'[n] == 1 + Sqrt[u[n] + 3], u[1] == 1}. – user64494 Nov 27 '23 at 19:23
  • Finally, since we don't know error when turning from RE to ODE, all that has not much sense. At best, our approaches (with and without ODEs) are heuristic. Also it's unclear how to compare the results. – user64494 Nov 27 '23 at 20:07
0

We can find an asymptotic solution by

AsymptoticRSolveValue[{u[n + 1] == u[n] + 1 + Sqrt[u[n] + 3],   u[1] == 1}, u[n], {n ,Infinity,3}]

6 - 6 n + n^2

Addition. The result of

nl = NestList[# + 1 + Sqrt[3 + #] &, 1.000000000000,  10^5];
 fL = #^2 - 6 # + 5 & /@ (Range@Length@nl); ListPlot[{fL/nl}]

enter image description here

suggests that the result of AsymptoticRSolve has the correct order of the growth up to the multiplier 1/4.

Let us find an asymptotic solution of {u[n + 1] == u[n] + 1 + Sqrt[u[n] + 3], u[1] == 1} in the form u[n_] := a*n^2 + b*n + c.

We substitute it in the recurrence equation and find the asmptotic at infinity by

Series[u[n + 1] - u[n] - 1 - Sqrt[u[n] + 3], {n, Infinity, 3}, 
Assumptions -> {a, b, c} \[Element] Reals && n > 1] // Normal

-1 + a + b - b/( 2 Sqrt[a]) + ((12 a - 5 b^2 + 4 a c) (12 a - b^2 + 4 a c))/( 128 a^(7/2) n^3) + (b (12 a - b^2 + 4 a c))/( 16 a^(5/2) n^2) + (-12 a + b^2 - 4 a c)/( 8 a^(3/2) n) + (-Sqrt[a] + 2 a) n

We want to cancel as many as possible terms in the above.

Solve[-Sqrt[a] + 2 a == 0, a, Reals]

gives a -> 1/4, The term -1 + a + b - b/( 2 Sqrt[a])==-3/4 cannot be cancelled. Now

Solve[{0 == -12 a + b^2 - 4 a c, 12 a - 5 b^2 + 4 a c == 0} /. 
a -> 1/4, {b, c}, Reals]

{{b -> 0, c -> -3}}

Hence, we draw the conclusion that u[n_]:=1/4*n^2-3 can be taken as an asymptotic solution.

user64494
  • 26,149
  • 4
  • 27
  • 56
  • But $n^2-6 n+6$ does not satisfy $u_{n+1} = u_n + 1 + \sqrt{u_n+3}$

    $$ $$ func[n_] = 6 - 6 n + n^2; func[2] == func[1] + 1 + Sqrt[func[1] + 3] (*False*)

    – ydd Nov 24 '23 at 17:51
  • @ydd: Yes, of course, "$6 - 6 n + n^2$ does not satisfy $u_{n+1} = u_n + 1 + \sqrt{u_n+3}$". This is an asymptotic formula for $u_n$ as $n$ tends to infinity. Look in the documentation tp AsymptoticRSolveValue – user64494 Nov 24 '23 at 17:55
  • I don't think it's asymptotically correct either: $$ $$ nl = NestList[# + 1 + Sqrt[3 + #] &, 1., 10000]; fL = #^2 & /@ (Range@Length@nl); ListPlot[{nl, fL}, PlotLegends -> {"true values", "asymp. values"}] plot $$ $$ I am also confused why AsymptoticRSolveValue can't solve the seemingly simpler AsymptoticRSolveValue[{a[n + 1] == a[n] + Sqrt[a[n]], a[1] == 1}, a[n], n -> Infinity] – ydd Nov 24 '23 at 18:17
  • Hope that Series[(6 - 6 (1 + n) + (1 + n)^2)/(6 - 6 n + n^2 + 1 + Sqrt[6 - 6 n + n^2 + 3]), {n, Infinity, 2}] which results in1+1/n+2/n^2+O[1/n]^3 is convincing. The difference in ListPlot[{nl, fL}] is caused by big round-of errors. "can't solve the seemingly simpler" is not any argument at all. – user64494 Nov 24 '23 at 18:29
  • Okay I am convinced. (Maybe even stronger: Limit[func[n + 1]/(func[n] + 1 + Sqrt[func[n] + 3]), n -> Infinity] (*1*)

    But it is still unclear why this is also given as the exact answer by RSolve as well. , because it only satisfies the recurrence relation at infinity

    – ydd Nov 24 '23 at 18:36
  • I don't know how to explain the results of RSolve[{a[x, n + 1] == a[x, n] + 1 + Sqrt[ a[x, n] + 3], a[x, 1] == 1}, a[x, n], n]. – user64494 Nov 24 '23 at 18:39
  • The result of nl = NestList[# + 1 + Sqrt[3 + #] &, 1.000000000000, 10^5]; fL = #^2 - 6 # + 5 & /@ (Range@Length@nl); ListPlot[{fL/nl} suggests that the multiplier 1/4 could be omitted in AsymptoticRSolveValue[{u[n + 1] == u[n] + 1 + Sqrt[u[n] + 3], u[1] == 1}, u[n], {n ,Infinity,3}]. – user64494 Nov 24 '23 at 19:10
  • Indeed, Series[-1/4*(6 - 6*(n + 1) + (n + 1)^2) + 1/4*(6 - 6 n + n^2) + 1 + Sqrt[1/4*(6 - 6 n + n^2) + 3], {n, Infinity, 3}] performs 3/4+9/(4 n)+27/(4 n^2)+243/(16 n^3)+O[1/n]^4 – user64494 Nov 24 '23 at 19:33
  • 1
    CASE:5093486 has been submitted by me. – user64494 Nov 25 '23 at 14:15