can someone show me how todo this. please put comments in code to explain what y
ID: 2081701 • Letter: C
Question
can someone show me how todo this. please put comments in code to explain what your are doing in the lines.
I'm using matlab.
Explanation / Answer
answer for
a) 9.2832=(800)^(1/3)
b) 38.9456=59071^(1/3)
c) -3.1599=(-31.55)^(1/3
code
clc
close all;
P=input ('enter the value of the number');
% x1=input('the first estimate of root');
x1=P;%choosing initial estimate
i=1:1:100;%choosing the number of iteration
x=zeros(1,length(i));%defining the length of x matrix
x(1)=x1;%initializing the first root as x1
for ii=1:1:length(i);
x(ii+1)=x(ii)*(x(ii)^3+2*P)/(2*x(ii)^3+P);%formula for finding root
E=abs((x(ii+1)-x(ii))/x(ii));%error for root
if E<0.00001 %using the if condition and break statement for terminating the loop when condition mets
break
end
Result=x(ii+1);
end
display (Result)
you can choose any initial value except zero in your question initial estimate is written as P
so i have choosen initial estimate as P
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.