You are on page 1of 3

ACM ASSIGNMENT-4

By

VIKASH KUMAR

14ME275
clc
clear
itreration=0;
v=30;
R=3;
r=1;
%Initial gauss
h=3;
while(r > 0.0005)
u=h;
vik = (pi*(h^2)*(3*R-h))/3 - v;
difvik = -(pi*h^2) + pi*R*2*h;
h = h - (vik/difvik);
r=abs((h-u)/h);
itreration=itreration+1;
end
fprintf('Itereration required %d.\n',itreration);
fprintf('answer is %f.\n',h);
fprintf('Error is %f.\n',r*100);

Output
Itereration required 3.
answer is 2.026906.
Error is 0.004424.
clc
clear
itreration=0;
B=20;
Q=5;
S=.0002;
n=0.03;
err=1;
%Initial gauss
h=8;
while(err > 0.0005)
u=h;
h =(( ( ( ((Q*n)^3)*((B+2*h)^2) ) /(S^(3/2)) )^(1/5))/B);
err=abs((h-u)/h);
itreration=itreration+1;
end
fprintf(iteration is %d. \n',itreration);
fprintf(Answer %f .\n',h);
fprintf('Error%f .\n',err*100);

Output
iteration is 4.
Answer 0.702299 .
Error 0.018956.

You might also like