Solving nonlinear equation using newton-raphson method
1 view (last 30 days)
Show older comments
Hello, I have this code that is wrong. I want to solve an equation (f) using newton's method. I want to update my old V value to the eqation for f and df, but I just can't get my head wrapped around it. Could anyone help please?
NB: The answer should be 0.86728 assuming the initial value of V is 0.
P=6;
T=2;
N = 500;
tol = 0.0001;
V = zeros(1,N);
f = zeros(1,N);
df = zeros(1,N);
del = 0;
Vnew = 0;
while del < tol
for i = 2:N
V(i) = Vnew;
f(i) = 3*P*V(i).^3 - P*V(i).^2 + 9*V(i) - 8*T*V(i).^2 - 3;
df(i) = 9*P*V(i).^2 - 2*P*V(i) - 16*T*V(i) + 9;
Vnew = V(i-1) - (f(i)/df(i));
end
del = V(i) - V(i-1);
end
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!