Problem in code for Newton Raphson Method
Mostrar comentarios más antiguos
if true
% code
function x = newton(x0)
tolerance = 10^(-8);
error = 999;
x = x0;
while error>tolerance
f = x-x^(1/3)-2; % Function value
dfdx = 1-(1/3)*x^(-2/3); % Derivative value
x = x-f/dfdx; % Newton-Raph Equation
error = abs(((x-x0)/x)*100);
x0 = x;
end
end
end
While executing this code I'm getting x = 0, which is not the intended answer. Please help.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!