Secant Method Research Paper
Secant Method Research Paper
INTRODUCTION
x3 = x2 − f(x2)(x1−x2)
f(x1)−f(x2)
Using the bisection method, find the roots of the equation 2x4+5x3+2x2+7x+10
when the tolerance is about 0.001.
III. METHODOLOGY
1. Start.
X3 = X2 –( f(X2)(X1-X2)/(f(X1) - f(X2)))
7. Print X3 as the root of the solution then repeat step 6 until the error becomes
smaller than the specified criterion.
8. End
The following code is used to find the roots of the equation f(x) =
2x4+5x3+2x2+7x+10. The code will ask the user to set two guesses and it will iterate
the value using Secant method to find the roots. The code can be modified allowing
the user to change the tolerance value requirements. This code utilizes the Microsoft
Excel VBA programming language feature and it runs using the Macros feature in
Microsoft.
Sub SecantMethodWithIterations()
Dim i As Integer
MsgBox "Invalid input. Please enter a numeric value for the initial guess x1."
Exit Sub
End If
MsgBox "Invalid input. Please enter a numeric value for the initial guess x2."
Exit Sub
End If
MsgBox "Invalid input. Please enter a numeric value for the tolerance."
Exit Sub
End If
On Error GoTo 0
maxIterations = 1000
Cells.ClearContents
ea = 100
For i = 1 To maxIterations
fx1 = 2 * x1 ^ 4 + 5 * x1 ^ 3 + 2 * x1 ^ 2 + 7 * x1 + 10
fx2 = 2 * x2 ^ 4 + 5 * x2 ^ 3 + 2 * x2 ^ 2 + 7 * x2 + 10
fx3 = 2 * x3 ^ 4 + 5 * x3 ^ 3 + 2 * x3 ^ 2 + 7 * x3 + 10
If i > 1 Then
End If
Cells(i + 1, 1).Value = i
Cells(i + 1, 2).Value = x1
Cells(i + 1, 3).Value = x2
Cells(i + 1, 6).Value = x3
Cells(i + 1, 8).Value = ea
Cells(2, 10).Value = x3
Cells(5, 10).Value = i
Exit For
End If
x1 = x2
x2 = x3
Next i
MsgBox "You have reached the maximum number of iterations. Try another value!"
End If
End Sub
V. ALGORITHM FLOW CHART
V. RESULTS
Using the Macros feature in MS Excel, the feature will run the program. The program
will ask for the value of the x1, x2, and tolerance. It will automatically calculate and iterate the
procedure until it reaches the tolerance value and stops. If the maximum number of iterations
is reached without finding the root, it displays an error message. This program is a practical
tool for solving mathematical problems using Excel.
Therefore, the root of the function f(x) = 2x4+5x3+2x2+7x+10 with a tolerance value of
0.001 is -2.31863 and -1.19872.
References:
https://www.geeksforgeeks.org/program-to-find-root-of-an-equations-using-secant-
method/
https://www.codesansar.com/numerical-methods/secant-method-using-c-
programming.htm