I need to evaluate the following series:
where u(n) is given by the recurrence relation:
The first and second terms are given as 0.5 and 0.6 respectively. The loop needs to end when un > 1e-8. The problem I have is that it seems that this series will never go below 0.5 so why even limit it to such a small number? Obviously the loop will just go on ad infinitum?
Anyway this is my code:
u(1) = 0.5;u(2) = 0.6;S = u;n = 1;while (abs(u(n)) >= 1e-8) n = n + 1; u(n+1) = u(n-1)^2 + u(n)^2; S(n) = u(n) + S(n-1);enddisp(S)
The first 6 cumulative terms I get with this code are 0.5; 1.1; 1.71; 2.4421; 3.35017; 4.71073 (in the array I defined as S), but then it rapidly moves up to infinity. I just want some confirmation on my code and whether I'm not misinterpreting something.
Best Answer