- #1
emergentecon
- 57
- 0
Homework Statement
Evaluate the following series ∑u(n) for n=1 → [itex]\infty[/itex] in which u(n) is not known explicitly but is given in terms of a recurrence relation.
You should stop the summation when u(n) < 10^(-8)
u(n+1) = (u(n-1))^2 + (u(n))2 with u(1) = 0.5, u(2) = 0.6
Note 1:The lecturer realized that the constraint: u(n) < 10^(-8) is an error and has stated that we can simply show that we managed to correctly code the recurrence relation, or solve it with the correct constraint.
Note 2: I am not looking for the answer, simply guidance on how to proceed / what I am doing wrong / not seeing?
Homework Equations
u(n+1) = (U(n-1))^2 + (u(n))2
u(1) = 0.5
u(2) = 0.6
The Attempt at a Solution
I have three attempts to this problem.
Attempt 1
I simply used excel to see how the values of u(n) evolved in order to verify any solution obtained in MATLAB . . . the values are:
0.61000000000000000
0.62210000000000000
0.75910841000000000
0.96325398813272800
1.50410382378633000
3.19018655838228000
12.43961859001160000
Attempt 2 - MATLAB
This implementation looks intuitively incorrect to me - plus the actual results to not correspond with what I attained in Excel.
clc; clear;
x1 = 0.5; x2 = 0.6; x3=0; counter=0;
while x1>10^-8;
counter=counter+1
x3 = x2 + x1;
x4 = x3 + x2;
x1 = x1^2;
x2 = x2^2;
x3
x4
end
Attempt 3 - MATLAB
This implementation looks more correct, but I get an error message? It is clearly missing the summation element, but am more concerned with getting the actual recurrence relation correct at this point.
clc; clear;
y(0) = 0.5; y(1) = 0.6; m = 0;
for m=1:10;
y(m+1)=(y(m))^2+(y(m-1))^2;
end
Error Mesage:
? Attempted to access (0); index must be a positive integer or logical.
Error in ==> New at 2
y(0) = 0.5; y(1) = 0.6; m = 0;