Newtons method x(i+1) = x(i) - f(x(i)/f '(x(i)), where f(x) is ideally 0. We do this until out f(x(i))=0. i is just the iteration that you perform.
First get one side to equal zero.
sin(x) = x2.
sin(x) - x2 = 0 Set this to f(x)
f(x) = sin(x) - x2 = 0. Find f ' (x)
f ' (x) = cos(x) - 2x
We pick a starting guess. We have to be careful about where we start. We generally pick a starting guess near a known solution. Graph the two values and observe that the only intersections are zero and approximately 1.
Make a table with i, y(i), f(y(i)), f ' (y(i)) to keep you organized. When you get a number close to zero for f(y(i)) you have found a solution. For this particular problem, you can terminate your iterations when the sixth decimal place stops changing.
Here are some of the iterations when we use 1 as a starting guess:
1
0.89139600
0.876984845
0.876726298
0.876726215
0.876726215
0.876726215
0.876726215
Note that the sixth decimal point stops changing.
Also note if we use -2 as a starting point, we get:
-2
-0.63016223
-0.153248303
-0.017213911
-0.000284854
-8.11E-08
-6.58E-15
-4.26E-29
0
0
0
0
So always determine visually, if possible, the correct starting point.
BTW, MATLAB code is as follows:
y(1)=1
for i =1:30
x(i+1)=x(i) - (sin(x(i))-x(i)^2)/(cos(x(i))-2*x(i));
end
x;
zero=sin(x)-x(i).^2;