I need to create a program which will allow me to use the secant method in order to solve a function. I need to run iterations of this function. I need to have the user enter 2 guesses at the beginning say they are verables a,b. Then I need the program to generate a sequence x2,x3,x4. Which should converge to the solution. I need to use the formula Xn+1=f(xn,xn-1). Then at the end of the program output the value of x, and f(x). The number of iterations can be no more than 1,000 and the width of the interval has to be less than .00001. If there is anyone who can just help me get started with this program that would be great. Thank you so much for the help!! This is urgent!!

What? Could you name the theorem that this is?

This is the secant method. That's what it is called. I am trying to create a program that will solve a function using the secant method. It is used in finding soluations of equations of one variable. The definition or formula that is used for the secant method is….

The Approximation Pn+1, for n>1, to a root of f(x) = 0 is computed from the approximation Pn and Pn-1 using the equation:

Pn+1 = Pn- (f(Pn)(Pn-Pn-1))/(f(Pn)-f(Pn-1)

There is two stopping conditions. First we assume that Pn is accurate when ABS(Pn-Pn-1) is witin the tolerance. Then also make sure that there is a maximum number of iterations given so that in case the method fails to converage as expected.

I hope this helps! I don't really understand what you mean by theorem. That is the function and the equation of the secant method.

Here's some more code from wikipedea this is a bit more difficult to port because it's in C

```
#include <stdio.h>
#include <math.h>
double f(double x)
{
return cos(x) - x*x*x;
}
double SecantMethod(double xn_1, double xn, double e, int m)
{
int n;
double d;
for (n = 1; n <= m; n++)
{
d = (xn - xn_1) / (f(xn) - f(xn_1)) * f(xn);
if (fabs(d) < e)
return xn;
xn_1 = xn;
xn = xn - d;
}
return xn;
}
int main(void)
{
printf("%0.15f\n", SecantMethod(0, 1, 5E-11, 100));
return 0;
}
```

If you need help with it pm me.

Hey is there anyway that you could tell me exactly what that program means? I have never programmed in C. Thanks!

Something that should be kept in mind when implementing the secant method is that one can set things up such that only one function evaluation is used for every iteration.

With that:

```
Input "F(X)=",Str1
String▶Equ(Str1,Y₁)
Prompt A,B,T
Y₁(A)→U
Y₁(B)→V
If A=B:Stop
0→I
Repeat abs(D)<T or I>40
I+1→I
V/((V-U)/(B-A))→D
B-D→X
Y₁(X)→F
B→A:X→B
V→U:F→V
End
X
```

thornahawk