Question
use Matlab. 2.7 part B please!

90, 60, 99: homework Tfor incluc exam=91. 2.7 The divide and average method, approximating the square root of any positive
0 0
Add a comment Improve this question Transcribed image text
Answer #1

format long
a = input("Enter a number: ");
squareRoot = 0;
if a > 0
tol = 10^-6;
x = a/2;

while 1
y = (x + a/x)/2;
e = abs((y-x)/y);
x = y;
if e < tol
squareRoot = x;
break;
end

end


else
squareRoot = 0;
end

fprintf("Squareroot of %f is %f",a,squareRoot);

============================================================================
SEE OUTPUT
Your Code format long a = input(Enter a number: ); squareRoot = 0; 1 if a > 0 4 5 tol = 10^-6; X = a/2; 7 while 1 (x + a/x)

Thanks, PLEASE COMMENT if there is any concern.

Add a comment
Know the answer?
Add Answer to:
use Matlab. 2.7 part B please! 90, 60, 99: homework Tfor incluc exam=91. 2.7 The "divide and average" method...
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
ADVERTISEMENT