Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

OBJECTIVE: Use loops to compute useful information You should work on this task

ID: 3597969 • Letter: O

Question

OBJECTIVE: Use loops to compute useful information You should work on this task individually, but you may discuss results with your teammates. What is the square root of 2019? Without using the v function of your calculator or computer. If you are patient, you can actually compute it by hand. But, you're not. So, you'll script it Guess that x-VS. Let the error in our estimate be e. Then, S = (x + e)2. Expand the binomial and solve for e: S-x2 2xe + e2-e- much less than x) Update the original guess by adding the error: x = x + e = x + Repeat until the new estimate changes by less than some specified amount from the previous estimate, e.g. 1Axl = IxNew-x0ld| 2019 2019 Our next estimate will be x -(x502945.18999... This is still an our next estimate will b45.93449340. This is sill an over-estimate Our next estimate will bex934020449333 This is very close t Our next estimate will bex 44.9333+203-449333 This is even close = 45.18999 This is still an over- estimate since (45.18999..)2- 2042.1361 > 4.81 2019. The change in the estimate is |Axl- 2019 -44.9340 This is still an over-estimate 45.1899 since (44.9340 )2-2019.0655 > 2019. The change in the estimate is = 0.2560. Our next estimate will be x =- 44.9340 since (44.9333 )2-2019.0000 2019. The change in the estimate is = 0.0007292. Our next estimate will be x = 44.9333 (44.9333 ..)2 2019.0000 2019. The change in the estimate is 4xl- 0.000000005916. The change in the estimate is small enough at this point (

Explanation / Answer

% Read number from user
num = input('Number to find the square root: ');
% First estimate value
estimate = 50;
% Change in exact and normal value
delta_x = 1;
% Repeat calculating new estimate value untill change in estimate becomes less than 10^-6
while delta_x > 10^(-6)
   % New esimated values
    new_estimate = 0.5*(estimate+num/estimate);
   % Change in estimate
    delta_x = abs(new_estimate-estimate);
   % Dispaly
   fprintf(' Next estimate is = %.6f Change in the estimate is = %.6f ',new_estimate,delta_x);
    estimate = new_estimate;
end
fprintf(' Approximate solution is %.6f ',estimate);