Error 6, Overflow for Newton Rhapson

CaraLeigh

New Member
Joined
Mar 2, 2014
Messages
1
Hi, an overflow error keeps occurring at the step where I calculate my FX. Have tried multiple ways, anyone able to help?? This is an algoritm for the Newton Rhapson method.

Thank you.

PHP:
Sub NewtonRhapsonMethod()

Dim a, E As Double      'a is the inputed initial value, E is the Accuracy(Epsilon)
Dim k, N As Integer
Dim FX, FDX, DL As Double   'FDX is the derivative of FX, FV is the functional value of the updated estimate

a = Cells(3, 7)
E = Cells(5, 7)
N = Cells(5, 8)
k = 1
Cells(2, 1) = k
Cells(2, 2) = a
a = x

Do While k <= N

FX = ((x) ^ 4) + (2 * ((x) ^ (2))) - (x) - (3)
FDX = 4 * (x) ^ 2 + 2 * (x) - 1

DL = -(FX) / (FDX)
x = x + DL
Cells(1 + k, 3) = DL
Cells(1 + k, 4) = x
Cells(1 + k, 5) = FX

If Abs(DL) <= 0 Then
    Cells(1 + k, 4).Select
    ActiveCell.Interior.ColorIndex = 36
    ActiveCell.Font.Bold = True
    Exit Sub
End If
If k > N Then
    MsgBox "Procedure is not successful"
    Exit Sub
End If
k = k + 1
Cells(1 + k, 1).Value = k
Loop
End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I don't think you'll find this condition
If Abs(DL) <= 0 Then
being satisfied very often.

Would you like to reconsider it?
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top