[COLOR=black]i am trying to compute a suite with matlab;[/COLOR]
[COLOR=black]the formula suite is [/COLOR]
[FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#228b22][FONT=Courier New][SIZE=2][COLOR=#228b22][FONT=Courier New][SIZE=2][COLOR=#228b22][FONT=Verdana][COLOR=black]sn = 1 - (2n*(2n-1)/(pipi))*s1(n-1) *[/COLOR][/FONT][/COLOR][/SIZE][COLOR=#228b22]
[SIZE=2][FONT=Verdana][COLOR=black]*where s0 = 2 *[/COLOR][/FONT][/SIZE]
[SIZE=2][FONT=Verdana][COLOR=black]and n is between 1 and 15[/COLOR][/FONT][/SIZE]
[SIZE=2][FONT=Verdana][COLOR=black]this is my code[/COLOR][/FONT][/SIZE]
[SIZE=2][FONT=Verdana][COLOR=#000000]%loop from 2 to 16[/COLOR][/FONT][/SIZE]
[/COLOR][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]
for n =2:16
%term 0
s(1) = 2;
%compute the nest term
s(n) = 1 - (2*n*(2.*n-1)/(pi*pi))*s1(n-1)
%display ther results
fprintf(' %2d %2d
',n-1,s(n-1));
end
the problem is am having weird results with an alternating sign.
ex for the 2 first terms in a normal calculation (outside the loop and using the same formula) give tthe following results:
s1 = 5.947152654306489e-001
s2 = 2.769129445167948e-001
while inside the loop from the code above i get
s1 = -1.431708e+000
s2 = 5.351872e+000
Does any body know why i do get differents results or how can i fix this? :puzzled:
[FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#228b22][FONT=Courier New][SIZE=2][COLOR=#228b22][FONT=Courier New][SIZE=2][COLOR=#228b22][FONT=Verdana][COLOR=#000000]thnks[/COLOR][/FONT][/COLOR][/SIZE][COLOR=#228b22]
[/COLOR][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]