Each equation has one real root Use Newtons Method to approx
Each equation has one real root. Use Newton’s Method to approximate the root to eight correct decimal places. (a) x5 + x = 1 (b) sin x = 6x + 5 (c) ln x + x2 = 3
**MUST BE DONE IN MATLABE AND SHOW CODE
Solution
program:
x=2; %initially take some value other than 0
count=0;
f=33; %calculate f(2) for the equation x^5+x-1
dx=1; % initially take dx as 1
x1=x;f1=f;
t=0.0000001; %used to run the loop till the value almost reaches to 0
while(dx > t || abs(f) > t)
count = count + 1;
fp=5*x^4 + 1;
xn = x - (f/fp);
dx = abs(x-xn);
x=xn;
f = x^5 + x - 1;
%displays in the order count x dx f
%12 is the minimum number of digits to display
%as given that approx to 8 decimal places
fprintf(\'%2i %12.8f %12.8f %12.8f\ \',count,x,dx,f);
end
output:
1 1.59259259 0.40740741 10.83786375
2 1.26581022 0.32678238 3.51550805
3 1.01173405 0.25407616 1.07179744
4 0.83993982 0.17179423 0.25800196
5 0.76598501 0.07395481 0.02967967
6 0.75507849 0.01090652 0.00052705
7 0.75487773 0.00020076 0.00000017
8 0.75487767 0.00000007 0.00000000
program:
x=1; %initially take some value other than 0
count=0;
f= -10.98254759; %calculate f(1) for the equation sin(x)-6*x-5
dx=1; % initially take dx as 1
x1=x;f1=f;
t=0.0000001; %used to run the loop till the value almost reaches to 0
while(dx > t || abs(f) > t)
count = count + 1;
df= cos(x) - 6;
xn = x - (f/df);
dx = abs(x-xn);
x=xn;
f = sin(x) - 6*x - 5;
%displays in the order count x dx f
%12 is the minimum number of digits to display
%as given that approx to 8 decimal places
fprintf(\'%2i %12.8f %12.8f %12.8f\ \',count,x,dx,f);
end
output:
1 -1.01156698 2.01156698 0.22173765
2 -0.97102598 0.04054100 0.00069061
3 -0.97089892 0.00012705 0.00000001
4 -0.97089892 0.00000000 0.00000000
program:x=1; %initially take some value other than 0
count=0;
f= -2; %calculate f(1) for the equation ln(x)+x^2-3
dx=1; % initially take dx as 1
x1=x;f1=f;
t=0.0000001; %used to run the loop till the value almost reaches to 0
while(dx > t || abs(f) > t)
count = count + 1;
df= (1/x) + 2*x;
xn = x - (f/df);
dx = abs(x-xn);
x=xn;
f = log(x) + x^2 - 3; %in matlab ln(x) is nothing but log(x)
%displays in the order count x dx f
%12 is the minimum number of digits to display
%as given that approx to 8 decimal places
fprintf(\'%2i %12.8f %12.8f %12.8f\ \',count,x,dx,f);
end
output:
1 1.66666667 0.66666667 0.28860340
2 1.59329292 0.07337375 0.00438522
3 1.59214322 0.00114971 0.00000106
4 1.59214294 0.00000028 0.00000000
5 1.59214294 0.00000000 0.00000000

