We need to solve the following equation to find the root
using the
Newton-Rapson method.
The iterative formula for the Newton-Rapson method can be given
as:
MATLAB code:
%%%%% root finding using the newton rhapson method
clc; clear;
s = 5281.716; % ft
L = 5280; % ft
syms x;
f = x - (s/L)*sin(x); %Given Function
g = diff(f,x); %The derivative of the function
i = 1;
err = 1;
theta(1) = 10; %the intial approximation
R(1) =s/(2*theta(1)); % intial value of R
d(1) = R(1)*(1-cos(theta(1))); % initial value of d
while err > 10^-8
theta(i+1)=theta(i)-subs(f,x,theta(i))/subs(g,x,theta(i)); %
formula of the method
err = abs(theta (i+1) - theta (i)); % error after each
iteration
R(i+1) = s/(2*theta(i+1)); % Radius after each iteration
d(i+1) = R(i+1)*(1-cos(theta(i+1))); % height after each
iteration
i =i+1;
end
fprintf('The final value of theta is : %f \n',theta(i));
fprintf('No. of Iterations : %d\n',i-1);
Output of the Code:
The Table containing
the values of , R and d after
each iteration
We were unable to transcribe this image
f(0)0-sin0 0
9(i1)i)- f(0.) f(0 )
Editor - CAUsers khantwallDesktop\Matlab Chegg Newton Rhapson.m pressuredrop.m regressioneqs.mx rungekutta1.m Current Folder NewtonRhapson.m Workspace 1 root finding using the newton rhapson method Name Value clc clear s 5281.716: ft 2 d 1x14 double 3 err 4.6214e-13 % ft 4 L 5280: f 1x1 sym 5 syms x 1x1 sym f x (s/L) *sin (x); %Given Function g diff (f, x) %The derivative of the function 6 f=X 15 7- L R 5280 i 1: 8 1x15 double 9- 1: err= 5.2817e+03 theta (1)= 10; %the intial approximation R (1)s/ (2 theta (1)); intial value of R d (1) R (1)* (1-cos (the ta (1))) ; initial value of d 10 theta x 1x15 double 11 - 1x1 sym 12 while err> 10-8 13 theta (i+l) theta ( i) -subs (f,x, theta (i) )/subs (g, x, theta (i)); 14 formula of the method err abs (theta (i+1)-theta (i)) % error after each iteration R (i+1) s/ (2*theta (i+l )): % Radius after each iteration d (i) R (i+1) (1-cos (theta (i+1))) 15 16 = - 17 height after each iteration i= i+1; 18 end 19 fprintf ('The final value of theta is f \n', theta (i)) fprintf ('No. of Iterations %d\n',i-1); 20 21 Command Window The final value of theta is: 0.044154 14 No. of Iterations IIIIIIIII
We were unable to transcribe this image
theta 10 4.26741457 0.65325189 0.4330393 0.28880102 0.19378583 0.1313902 0.09099833 0.06582614 0.05162548 0.04551466 0.04421247 0.0441539 0.04415378 0.04415378 R 264.0858 618.842617 4042.63356 6098.42577 9144.2128 13627.7145 20099.3535 29020.9506 40118.6815 51154.1614 58022.1406 59731.0637 59810.3014 59810.4594 59810.4594 d 485.672676 885.214004 832.331374 562.917875 378.698089 255.080679 173.241981 120.07394 86.8873651 68.1526387 60.0885027 58.3699215 58.2926172 58.2924632 58.2924632