x1 = 0.1; x = newton(@f, @dfdx, x1, 20); length(x) function y = f(x) % F demonstrate the case of divergence for Newton's method alpha = 0.001; y = x/(alpha^2 + x^2); end function y = dfdx(x) % DFDX demonstrate the case of divergence for Newton's method alpha = 0.001; y = (alpha^2 - x^2)/(alpha^2 + x^2)^2; end