Question

is O1. The olume I of liquid in a hollow horizontal cylinder of radius r and length related to the depthh h of the liquid by

0 0
Add a comment Improve this question Transcribed image text
Answer #1


Matlab code for Newton Method clear all close all syms h function for which root have to find 1-5 fun(h)=(r^2* acos ( (r-h) /symbolic function inpu ts: h iterations Using Newton After 1 iteration Value of h=0.801774 Function value is 0.974297 Derivat

%Matlab code for Newton Method
clear all
close all

syms h
%function for which root have to find
r=2; l=5;
fun(h)=(r^2*acos((r-h)/r)+(h-r)*sqrt(2*r*h-h^2))*l-8;
g1(h) =diff(fun,h);   %1st Derivative of this function
xx=1.5;            %initial guess]
%function for Newton method
fprintf('Function for Newton method f(h)=\n')
disp(vpa(fun,3))

fprintf('\nDerivative of the function is df/dh=\n')
disp(vpa(g1,3))

fprintf('\nUsing Newton iterations\n')

%Loop for all intial guesses
    n=0.0001; %error limit for close itteration
    for i=1:500 %maximum iterations
      
        x2=double(xx-(fun(xx)./g1(xx))); %Newton Raphson Formula
        cc=abs(x2-xx);                   %Relative Error
        err(i)=cc;
        xx=x2;
      
        fprintf('\nAfter %d iteration\n',i)
        fprintf('Value of h=%f\n',xx)
        fprintf('Function value is %f\n',fun(xx))
        fprintf('Derivative of the function %f\n\n',g1(xx))
      
        if cc<=n
            break
        end
      
      
    end
    root=xx;

fprintf('\n\tDepth h of the liquid is %f m\n',root)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
is O1. The olume I of liquid in a hollow horizontal cylinder of radius r and length related to the depthh h of the l...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT