This document describes the Newton method for finding the roots of a function. It presents the formulas for calculating the derivative of a function and updating the estimate of the root in each iteration. The Visual Basic code implements Newton's method by allowing the user to input coefficients a, b, c, d and an initial estimate x, and then calculates successive estimates until a solution is found within a tolerance of 0.0001.
This document describes the Newton method for finding the roots of a function. It presents the formulas for calculating the derivative of a function and updating the estimate of the root in each iteration. The Visual Basic code implements Newton's method by allowing the user to input coefficients a, b, c, d and an initial estimate x, and then calculates successive estimates until a solution is found within a tolerance of 0.0001.
This document describes the Newton method for finding the roots of a function. It presents the formulas for calculating the derivative of a function and updating the estimate of the root in each iteration. The Visual Basic code implements Newton's method by allowing the user to input coefficients a, b, c, d and an initial estimate x, and then calculates successive estimates until a solution is found within a tolerance of 0.0001.
Private Sub Command1_Click() Dim a As Single, b As Single, c As Single, d As Single, x As Single a = Text1.Text b = Text2.Text c = Text3.Text d = Text4.Text Text5.Text = 3 * a Text6.Text = 2 * b Text7.Text = c Label6.Caption = "X^2" Label8.Caption = "X" Label5.Caption = "F(X)" x = Text8.Text End Sub
Private Sub Command2_Click()
Dim a As Single, b As Single, c As Single, d As Single, x As Single
a = Text1.Text b = Text2.Text c = Text3.Text d = Text4.Text x = Text8.Text Text9.Text = ((a * x ^ 3) + (b * x ^ 2) + (c * x) + d) / ((3 * a * x ^ 2) + (2 * b * x) + c) If Text9.Text > 0.0001 Then Text10.Text = ((a * (Text9.Text) ^ 3) + (b * (Text9.Text) ^ 2) + (c * (Text9.Text)) + d) / ((3 * a * (Text9.Text) ^ 2) + (2 * b * (Text9.Text)) + c)
Label11.Caption = "interaccion 2"
Label15.Caption = "X2 = " End If If Text10.Text > 0.0001 Then Text11.Text = ((a * (Text10.Text) ^ 3) + (b * (Text10.Text) ^ 2) + (c * (Text10.Text)) + d) / ((3 * a * (Text10.Text) ^ 2) + (2 * b * (Text10.Text)) + c) Label12.Caption = "interaccion 3" Label16.Caption = "X3 = " End If