function that applies the secant method to iteratively approximate the nth root of a constant given n, the constant, and two initial guesses--x0 and x1.

What will be an ideal response?

```
double secant( double c, double n, double x0, double x1 )
{
int i;
double tmp, tmpn, tmpd;

for( i = 2; (x0-x1) > TOLERANCE && i <= MAX_ITERATIONS; i++)
{
tmpn = ( x0 * ( pow(x1, n) - c ) - x1 * ( pow(x0, n) - c ) );
tmpd = ( (pow(x1 ,n) - c) - (pow(x0, n) - c) );

tmp = tmpn / tmpd;

x0 = x1;
x1 = tmp;
}

//if no convergence after MAX_ITERATIONS iterations,
//display error message and return 0
if( x0 - x1 > TOLERANCE)
{
cerr << "Error in function 'secant'...no convergence" << endl;
return 0;
}

return x1;
}

```

Computer Science & Information Technology

You might also like to view...

There are ________ points to an inch

Fill in the blank(s) with correct word

Computer Science & Information Technology

Match the following terms with their descriptions:

I. Fixed-length text file II. Hyperlink III. Importing IV. Linking V. Text file A. Data type to link to a file on your computer or a webpage B. Connects to an external file without copying the records to the existing table C. Common file formats used for exchanging data D. Copies external data without maintain a link to the external file E. Allocates a certain number of characters for each field

Computer Science & Information Technology