1
$\begingroup$

I am looking for the fastest way to implement the secant method (the one which is used for finding roots to a given single-variable equation) on a fx-991es calculator (scientific, non programmable calculator). What I have done till now:

  1. Assign initial values to A,B,C,D (Later the variables will serve as A = $x_{n-1}$, B = $x_n$, C = $x_{n+1}$, $D = f(x_{n-1})$, $E = f(x_n)$)
  2. Perform the operation $\frac{AE-BD}{E-D} \rightarrow C$, followed by the operations $B \rightarrow A, E \rightarrow D, C \rightarrow B$. Then, perform $f(C)\rightarrow E$. For example: ($cos(c)-c e^c \rightarrow E$)
  3. Repeat step 2 till the desired accuracy is reached.
    I found this pretty useful in implementing Regular-Falsi(False position) method/ bisection method, as only one set of variables is replaced there (A,D or B,E).
    However, navigating history after each operation 2 takes some time (to find the operation, then implement $\frac{AE-BD}{E-D} \rightarrow C$). Also, there are multiple replacement operations. Please post a shorter solution, if possible. A general comment on implementing numerical solutions using calculator (for other methods) would be helpful too.
    About the calculator: It has 9 variables for storage option (including M), operations supported in Vectors, Matrices too. Maybe a 2-d vector solution to this problem can be found.
    Note: I am aware that on the computer(Matlab)/programmable calculator, the process can be automated. However, I require a solution which is doable using a non-programmable calculator as these options are not available in the exam. So, please don't post such comments.
$\endgroup$
2
  • 1
    $\begingroup$ You are currently calculating $C$ in a manner which will cause subtractive cancellation. This will (severely) limit the accuracy that you can achieve. You really need to compute $x_{n+1} = x_n - f(x_n) a_n$ where $a_n = \frac{x_n - x_{n-1}}{f(x_n)-f(x_{n-1})}$ to avoid this. There are alternatives, but those are expensive. $\endgroup$ Commented Jan 15, 2021 at 15:48
  • $\begingroup$ @CarlChristian I have made an edit. Sorry, while posting the question, I had mentioned the wrong operations. The formula is working fine, I have solved atleast 15 problems with the correct answer (convergent) using the above algorithm. The only problem is that it takes a bit of time. Accuracy is not an issue, as I said, I have to solve this question in exams not in real life projects. $\endgroup$
    – IamThat
    Commented Jan 15, 2021 at 16:04

1 Answer 1

3
$\begingroup$

Not only does the form

$$x_{n+1}=x_n-\frac{f(x_n)}{f(x_n)-f(x_{n-1})}(x_n-x_{n-1})$$

provide more numerical stability, it can also be implemented with fewer variables (and hence less updates per iterations) since it can be rewritten as

\begin{cases}x_{n+1}=x_n+\Delta x_n\\\Delta x_n=\dfrac{f_n}{f_{n-1}-f_n}\Delta x_{n-1}\\f_n=f(x_n)\end{cases}

which requires only one value of $x$, one value of $\Delta x$, and two values of $f$ per iteration:

  1. Initialize $(A,B,C,D)=(x_1,\Delta x_0,f_1,f_0)=(x_1,x_1-x_0,f(x_1),f(x_0))$.

  2. Update $B:=\dfrac{BC}{D-C}$, then $A:=A+B$, then $D:=C$, then $C:=f(A)$.

  3. Repeat 2. until desired accuracy.

$\endgroup$
1
  • $\begingroup$ Thank you. This is exactly the kind of answer I was looking for. $\endgroup$
    – IamThat
    Commented Jan 16, 2021 at 10:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .