solves equation of circular segment

%RAPHSON solves equation of circular segment .
% The Newton-Raphson method.

A = 0.0472; r = 2;
y0 = 2*A/r^2;
y  = ‘x – sin(x) -y0’
dydx = ‘1 – cos(x)’
guess = pi/5;
x = guess;
angle = [ x x ];
iter = [ 0 (x – sin(x) – y0) ];
for i = 1:100
x0 = x;
x = x0 – eval(y)/eval(dydx)
angle = [ angle x x ];
iter  = [ iter 0 eval(y) ];
if abs(x – x0) < 0.00001
break
end
end
xx = 0.5: 0.010: 0.65;
yy = xx – sin(xx) – y0;
plot(xx, yy, angle, iter)
grid
xlabel(‘phi’)
title(‘Newton iterations for x – sin(x) – 2A/r^2 = 0’)
text(0.15, 0.85, ‘solid line … y = f(x)’, ‘sc’)
text(angle(1), 0, ‘x0’)
text(angle(2), iter(2), ‘f(x0)’)
text(angle(3), iter(3), ‘x1’)
text(angle(4), iter(4), ‘f(x1)’)
text(angle(5), iter(5), ‘x2’)