Question: 2 Lab Assignment During this lab period, complete the following. Check out with one of the TAs showing your MATLAB workspace and m-file for

 

 

2 Lab Assignment During this lab period, complete the following. Check out

2 Lab Assignment During this lab period, complete the following. Check out with one of the TAs showing your MATLAB workspace and m-file for the codes. Turn in the lab report template with your answers to the specified questions written on it and a single m-file containing your codes and their outputs in comments. 1. The "divide and average" method is an old-time method for approximating the square root of any positive number a. This method starts with a guess at the square root, x, and then iterates on the value of x using the formula: x = x+a 2 With this approach, the error in the calculation, E can be calculated as: = -x new old - |-| new (1) (2) Write an m-file that calculates the square root of a number that is entered by the user. Your program must: a) Include a while loop b) Have a user defined variable that defines the initial guess at the square-root c) Have a variable that defines the target error, which may or may not be input by the user. An error of = 104 to 106 is the range at which your code should operate. d) Calculate the error at each iteration of the calculation and plot error versus iteration e) Plot the calculated square root versus iteration Run your program several times to calculate the square roots of different numbers. Record your observations to the following and turn in with your code: a. How does the value of the initial guess change the speed at which the calculation converges to the final answer? b. Can you think of a better way to provide the initial guess instead of just specifying a number? c. Discuss the importance of specifying the appropriate tolerance or error for an engineering calculation. What happens if you require too fine of a tolerance?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mechanical Engineering Questions!