Determination of any roots of any function by Newton Raphson method is known. One condition function must be continous and derivable.
According to the Newton Raphson method, root of a function can be calculated by the following method;
This equation gets closer to the root as a result of consecutive iterrations. However, the potential hardness is that taking derivatives becomes very though and time consuming for some functions.
This is the main idea of secant method. When we define calculations of derivatives, the formula to determine root becomes like the following form.
Last obtained equation is known as secant method. Secant method is an open method. It can be observed that how it is tending to the root.
Red line indicates the function we search for. Roots of blue lines are the ones determined after each iterrations.
MatLab Script Code for Secant Method
x(1)=input('enter first guess: ');
x(2)=input('enter second guess: ');
n=input('enter tolerance: ');
x(i) = x(i-1) - (f(x(i-1)))*((x(i-1) - x(i-2))/(f(x(i-1)) - f(x(i-2))));
Visual Basic Code for Secant Method
Public Class Form1
Private Function f(ByVal X As Double) As Double
Dim a As Double
Dim b As Double
Dim c As Double
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
Return a * X ^ 2 - b * X + c
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim u As Double
Dim d As Double
Dim k As Double
Dim tol As Double
u = Val(TextBox4.Text)
d = Val(TextBox5.Text)
tol = Val(TextBox6.Text)
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = 100
For i = 1 To 10000
k = u - (f(u) * ((u - d) / (f(u) - f(d))))
u = k
ProgressBar1.Value = 100
If Math.Abs((k - u) / k) * 100 < tol Then
SECANT METHOD EXAMPLE MANUAL SOLUTION
Using secant method, determine the roots of the function of