# Represent and evaluate an infinite expression

I am trying to represent this in Mathematica, then evaluate it:

1*Sqrt[6 +
2*Sqrt[7 +
3*Sqrt[8 +
4*Sqrt[9 +
5*Sqrt[10 +
6*Sqrt[11 +
7*Sqrt[12]]]]]]] // N
...


The values go on infinitely with embedded square roots. The values are $$1,2,3,4,\dots$$ in front of the roots and $$6,7,8,9,\dots$$ in the body of the root in a telescoping fashion. I am only showing 7 of them here.

This expression resolves to $$4$$. How do we simply represent it under one Limit using, I assume, a starting point of $$n$$ and $$n+5$$ which go through to $$\infty$$?

P.S. Also: is there a Mathematical way of proving/computing this manually as a Limit?

• The expression is not a sum so it cannot be achieved with Sum. Commented Jul 30 at 21:36
• Yes correct, I meant Limit....i will update the question now... Commented Jul 31 at 3:01

FoldList[#1 /. x -> #2*Sqrt[(#2 + 5) + x] &, x, Range[7]]
% /. x -> 0 // N


{0., 2.44949, 3.36028, 3.72428, 3.87774, 3.94474, 3.97468, 3.98828}


Update:

To get exact result we can write down relation between a[n] and a[n+1] and then solve it (also guessing that the form of a[n] is a[n] == p n + q which may be obvious from their relation).

Clear[a, n, p, q]

a[n] == Sqrt[5 + n + (n + 1) a[n + 1]]
a[n + 1] == SolveValues[ApplySides[#^2 &, %], a[n + 1]][[1]]
a[n_] := p n + q
eq = %%
CoefficientList[Numerator[Factor[SubtractSides[eq][[1]]]], n] == 0 //
Solve // First
a[1] /. %

Clear[a, n, p, q, eq]


• Nice , WOW! @azerbajdzan: Can we enhance this to get the Limit of it going to Infinity and just evaluate it as a Limit? to get a precise 4.0 as the output? Commented Jul 31 at 3:07
• @Steve237 I updated my answer with method how to get exact result. Commented Jul 31 at 20:50

Here is a way, similar to @azerbajdzan but without using a placeholder token:

MyExpression[n_] := Fold[#2*Sqrt[#2 + 5 + #1] &, 0, Reverse@Range@n];

MyExpression[7]
(* Sqrt[6 + 2*Sqrt[7 + 3*Sqrt[8 + 4*Sqrt[9 + 5*Sqrt[10 + 6*Sqrt[11 + 14*Sqrt[3]]]]]]] *)


Note that the innermost expression was simplified automatically by Mathematica, but is equivalent to 7*Sqrt[12].

A modification of azerbajdzan's solution using FixedPointList

\$Version

(* "14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)" *)

Clear["Global*"]

prec = 9;

n = 1; (seq =
FixedPointList[# /. x -> n*Sqrt[((n++) + 5) + x] &, x,
SameTest -> ((Abs[#1 - #2] /. x -> 0) < 10^(-prec) &)]) // Short


Length@seq

(* 31 *)

N[seq /. x -> 0, prec]

(* {0, 2.44948974, 3.36028312, 3.72428093, 3.87774469, 3.94474032, 3.97467868, \
3.98827832, 3.99453082, 3.99743200, 3.99878796, 3.99942546, 3.99972665, \
3.99986953, 3.99993755, 3.99997004, 3.99998559, 3.99999306, 3.99999665, \
3.99999838, 3.99999922, 3.99999962, 3.99999982, 3.99999991, 3.99999996, \
3.99999998, 3.99999999, 3.99999999, 4.00000000, 4.00000000, 4.00000000} *)

• Nice! Does this mean on the 29th iteration we get precisely 4.0? Or is the output just a rounded to that? Oh yes see the prec=9 .... Ok! Commented Jul 31 at 3:08
• Look at N[seq /. x -> 0, prec][[-3 ;;]] // InputForm Commented Jul 31 at 4:23

for fun, you can use Nest with reverse direction.

n = 7;
Nest[n*Sqrt[((n--) + 5) + #] &, x, 7]
`