have Newton's Method working, but the second part of the question asks;
'Now use your Newton's method code to calculate the root for a range of values of C from C=-5 to C=5 in steps of 0.5. Plot the root obtained for different values of C.
I have used nested FOR loops to try and answer the problem, but nothing is coming up on my graph. The code is just below, I'd appreciate it if someone could tell me where I'm going wrong? Thanks =)
x0=-8;
x=x0;
N=5
for C==5:0.5:5
for N=1:5
f=(0.5*x^2)+(4*x)+(3*cos(x))+C;
df=x+4-sin(x);
x=x-(f)/(df)
end
solution=x
end
plot(C,solution)
'Now use your Newton's method code to calculate the root for a range of values of C from C=-5 to C=5 in steps of 0.5. Plot the root obtained for different values of C.
I have used nested FOR loops to try and answer the problem, but nothing is coming up on my graph. The code is just below, I'd appreciate it if someone could tell me where I'm going wrong? Thanks =)
x0=-8;
x=x0;
N=5
for C==5:0.5:5
for N=1:5
f=(0.5*x^2)+(4*x)+(3*cos(x))+C;
df=x+4-sin(x);
x=x-(f)/(df)
end
solution=x
end
plot(C,solution)
-
plot
must be into the loop
i think x must be ploted
must be into the loop
i think x must be ploted