Here’s my code:
x=0;
for i=1:100
x=x+sqrt(((1/((((2*i)-2)^2)*(((2*i)+2)^2)))*16)+8);
end
For some reason I keep getting the infinity value (inf) for x after this operation???
Can someone help explain why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That is because you divide by zero at
i==1: Take a look at(2*i)-2wherei==1.I can only guess that you actually meant to use
ias the imaginary square root of-1. In that case, change the loop to:And in that case the loop is not necessary at all.