Write a SUB PROCEDURE in VBA code to implement BISECTION met

Write a SUB PROCEDURE in VBA code to implement BISECTION method. Then apply the sub procedure to find the root of below non-linear equation: f(x) = e^2x - 3x - 50 = 0 Start the iteration with initial trial: a^(t) = 0 and b^(t) = 5. Stop iteration with the criteria epsilon less-thanorequalto 0.01. Specific requirements: return all data from each iteration step to worksheet using following format and highlight your final solution of the root in the worksheet.

Solution

\'declare variables
Dim n As Double
Dim o As Double
Dim p As Double
Dim m As Double
Dim expression As Double

Sub retrieveinputs()
\'getting value from excel sheet
m = Cells(4, 3)
n = Cells(5, 3)
o = Cells(6, 3)
p = (n + o) / 2
expression = Cells(8, 3)
End Sub

Sub getroot()
   Dim fm As Double
   Dim fn As Double
   Dim fo As Double
   Dim k As Integer
   Dim n As Integer
   n = Cells(9, 3)
   Do Until k <= n
       k = Cells(10, 3)

       Do Until Abs(fm) <= m
           fn = 2 * (n - 2) ^ 2 - expression ^ n
           fo = 2 * (o - 2) ^ 2 - expression ^ o
           fm = 2 * (p - 2) ^ 2 - expression ^ p
           p = Cells(2, 4)
           fn = Cells(2, 5)
           fo = Cells(2, 6)
           fm = Cells(2, 7)
           If fm * fn < 0 Then
               o = p
           End If
           If fm * fo < 0 Then
               n = p
           End If
       Loop
       k = k + 1
   Loop
End Sub

 Write a SUB PROCEDURE in VBA code to implement BISECTION method. Then apply the sub procedure to find the root of below non-linear equation: f(x) = e^2x - 3x -

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site