clcclear allclose all% f(x) = x^3 - x -3;
% devf(x) = diff(x^3 - x - 3);
Ea = 100;m = 0;k = 0;1i;x0=(-2-2*i);display(' k realx imagx abs(f(xk)) '); while abs(x0^3 - x0 - 3)>10^-5 if m < 50 x1 = x0 - ((x0^3 - x0 - 3) ./ ((3 * x0)^2 - 1)); Ea = abs(((x1 - x0) / x1) * 100); realx=real(x0); imagx=imag(x0); fprintf('%2.0f %12.5f %12.5f %12.5f %12.5f\n', k , realx, imagx, abs(x0^3 - x0 - 3)) k = k + 1; x0 = x1; else break end m = m + 1;end
MATLAB: How can we write our values in a column
column
Best Answer