%% Cuencas de convergencia close all clc clear % gamma = 2; % f = @(x) abs(x).^gamma; % df = @(x) gamma.*abs(x).^(gamma-1).*sign(x); f = @(x) (x+3).*(x-1).*(x-4);%x.^3 - 2*x.^2 - 11*x + 12; % = (x+3)*(x-1)*(x-4) df = @(x) 3*x.^2 - 4*x - 11; x = 2.354; % 2.352, 2.353, 2.354 xprev = inf; % x = 2; % xprev=inf; plot(linspace(-4,5), f(linspace(-4,5))) hold on plot(linspace(-4,5), 0*linspace(-4,5), '--k') hold on plot(x,f(x), 'ok', 'MarkerSize', 4, 'MarkerFaceColor', 'k') n_Newton = 0; x_Newton = [x]; while abs(x - xprev) > 1e-3*abs(x) xprev = x; x = x - f(x)/df(x); pause plot(x,f(x), 'ok', 'MarkerSize', 4, 'MarkerFaceColor', 'k') n_Newton = n_Newton + 1; x_Newton = [x_Newton; x]; end n_Newton x_Newton