Question: Write your own squareroot function named double my_ squareroot _1 (double n) using the following pseudocode: x = 1 repeat 10 times: x = (x

 Write your own squareroot function named double my_ squareroot _1 (double

Write your own squareroot function named double my_ squareroot _1 (double n) using the following pseudocode: x = 1 repeat 10 times: x = (x + n/x)/2 return x and then write a main which prints n, squareroot (n), and my_ squareroot _1(n) for n = 3.14159 times 10 to the k^th power for k = -100, -10, -1, 0, 1, 10, and 100. Use this C++11 code (which may not work on older versions of Visual Studio): for (auto k: {-100, -10, -1, 0, 1, 10, 100}){ n = 3.14159 *pow(10.0, k);//cout goes here } Modify problem 1 to also print the relative error as a per cent, by adding a column relative_error_per_cent = 100*((my_ squareroot _1(n)- squareroot (n)/ squareroot (n). Line up the columns using setw0, etc. Name your program hw2pr2.cpp

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 Databases Questions!