Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Important note: please, make sure to write the code by accurately following the

ID: 673173 • Letter: I

Question

Important note: please, make sure to write the code by accurately following the intructions given in the question. Make sure to write down the function and the script file. I've asked for help in MATLAB questions before, and people answered it with different methods than the one specifically mentioned in the question. Also, tell me which code belongs to the function file and which code belongs to the script file,so writing comments to explain the code would be highly appreciated. I posted this question previously, but the code either didn't work, or didn't follow the intructions in the question so I would also really appreciate it if you could test the code before giving me the answer and also make sure that it follows the instructions. Thank you so much

Explanation / Answer

clear all
close all
clc
% Change here for different functions
f=@(x) x1^3-10x1+x2-x3+3 = 0
%this is the derivative of the above function
df=@(x1) 3x1-10 = 0
% Change lower limit 'a' and upper limit 'b'
a=0; b=1;
x=a;
for i=1:1:100
x1=x-(f(x)/df(x));
x=x1;
end
sol=x;
fprintf('Approximate Root is %f 0.2',sol)
x1^3-10x1+x2-x3+3 =0
a=0;b=1;
x=a;
er(5)=0;
for i=1:1:5
x1=x-(f(x)/df(x));
x=x1;
er(i)=x1-sol;
end
plot(er)
xlabel('Number of iterations')
ylabel('Error')
title('Error Vs. Number of iterations')


2)

x2^3+10x2-2x1-2x3-5 =0

clear all
close all
clc
% Change here for different functions
f=@(x) x2^3+10 x2-2 x1-2 x3-5 = 0

%this is the derivative of the above function
df=@(x2) 3 x2^2+10 = 0
% Change lower limit 'a' and upper limit 'b'
a=0; b=1;
x=a;
for i=1:1:100
x1=x-(f(x)/df(x));
x=x1;
end
sol=x;
fprintf('Approximate Root is %f 0.2',sol)
x1^3-10x1+x2-x3+3 =0
a=0;b=1;
x=a;
er(5)=0;
for i=1:1:5
x1=x-(f(x)/df(x));
x=x1;
er(i)=x1-sol;
end
plot(er)
xlabel('Number of iterations')
ylabel('Error')
title('Error Vs. Number of iterations')


3)

x1+x2-10x3+2sin(x3)+5 = 0

clear all
close all
clc
% Change here for different functions
f=@(x) x1+x2-10x3+2sin(x3)+5 = 0

%this is the derivative of the above function
df=@(x3) cos(x3)-5 = 0

% Change lower limit 'a' and upper limit 'b'
a=0; b=1;
x=a;
for i=1:1:100
x1=x-(f(x)/df(x));
x=x1;
end
sol=x;
fprintf('Approximate Root is %f 0.2',sol)
x1^3-10x1+x2-x3+3 =0
a=0;b=1;
x=a;
er(5)=0;
for i=1:1:5
x1=x-(f(x)/df(x));
x=x1;
er(i)=x1-sol;
end
plot(er)
xlabel('Number of iterations')
ylabel('Error')
title('Error Vs. Number of iterations')