say you have a function
y=10+2k
so when
k=0, y=10
k=1, y=12
k=2, y=14
im trying to make a loop so that the current function is added to the previous function
so when k is equal to 2 it should output 26
it would be best to code in python please
to be more specific... im trying to make it so that the function S keeps adding to its previous function in the loop untill Sp1-S>0.01
Code
function S=matcos(A)
k=0;
S= (-1)^(k)*A^(2*k)/factorial(2*k)
Sp1= (-1)^(k+1)*A^(2*(k+1))/factorial(2*(k+1))
while somefunc max(abs(Sp1-S))>0.01;
k=k+1;
Sp1=S+%something
end
end
This post was edited by xMaxPower on Sep 24 2012 04:16pm