Numerical Methods for Engineers

Published by McGraw-Hill Science/Engineering/Math
ISBN 10: 0073401064
ISBN 13: 978-0-07340-106-5

Chapter 2 - Programming and Software - Problems - Page 48: 2.7a

Answer

IF a>0 $\ \ \ \ $tol=0.000001 $\ \ \ \ $x=a/2 $\ \ \ \ $DO $\ \ \ \ $$\ \ \ \ $y=(x+a/x)/2 $\ \ \ \ $$\ \ \ \ $e=abs|(y-x)/y| $\ \ \ \ $$\ \ \ \ $x=y $\ \ \ \ $$\ \ \ \ $IF e < tol EXIT $\ \ \ \ $ENDDO $\ \ \ \ $SquareRoot=x ELSE $\ \ \ \ $SquareRoot=0 ENDIF

Work Step by Step

IF a>0 $\ \ \ \ $tol=0.000001 $\ \ \ \ $x=a/2 $\ \ \ \ $DO $\ \ \ \ $$\ \ \ \ $y=(x+a/x)/2 $\ \ \ \ $$\ \ \ \ $e=abs|(y-x)/y| $\ \ \ \ $$\ \ \ \ $x=y $\ \ \ \ $$\ \ \ \ $IF e < tol EXIT $\ \ \ \ $ENDDO $\ \ \ \ $SquareRoot=x ELSE $\ \ \ \ $SquareRoot=0 ENDIF
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.