I have to write my own square root function using:
x=n-1
return 1+(1/2)x-(1/8)x^2+(1/16)x^3-(5/128)x^4
it will be named "doublemy_sqrt_1(double n)"
then write a main that prints n, sqrt(n) and my file for n=3.14159*10^kth for k=-100, -10, -1, 0, 1, 10, and 100.
I am supposed to use the code
then I need to modify it so I can print the relative error as a percent, by adding a column
THANKS IN ADVANCE!
x=n-1
return 1+(1/2)x-(1/8)x^2+(1/16)x^3-(5/128)x^4
it will be named "doublemy_sqrt_1(double n)"
then write a main that prints n, sqrt(n) and my file for n=3.14159*10^kth for k=-100, -10, -1, 0, 1, 10, and 100.
I am supposed to use the code
for(auto k: {-100, -10, -1, 0, 1, 10, 100}){
n=3.14159*pow(10.0, k);
//cout goes here
}
then I need to modify it so I can print the relative error as a percent, by adding a column
relative_error_per_cent=100*((my_sqrt_1(n)-sqrt(n))/sqrt(n). Line up the columns using
setw(), ect.
THANKS IN ADVANCE!