Basically I want to compute $x_{n+1} = (1/2)(x_n + 5/x_n)$.
On Mathematica, I wrote
h[1] := 2
h[n_] := h[n + 1] = (1/2)*(h[n] + 5/h[n])
h[2]
When I tried to compute h[2], I get this error message $RecursionLimit::reclim: "Recursion depth of 256 exceeded.
It works for easier sequences like f[n] = n f[n+1]. What is wrong?
h[n_] := h[n] = (1/2)*(h[n-1] + 5/h[n-1]). – J. M.♦ Oct 7 '12 at 2:27Clearyour previous definitions ofhfirst? – rcollyer Oct 7 '12 at 2:43h[1] := 2; h[n_] /; n >= 2 := h[n] = (1/2)(h[n - 1] + 5/h[n - 1])implements the intended recursion. – whuber Oct 7 '12 at 19:42