431,745 Members | 1,897 Online + Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,745 IT Pros & Developers. It's quick & easy.

# Newton Raphson's Method for solving an equation

 P: 1 Please,I need a program in visual basic to solve the question below: -By applying Newton Raphson method,find the root of 3x-2tanx=0 given that there is a root between pie/6 and pie/3.Thank you. Jan 30 '08 #1
4 Replies

 100+ P: 491 Please,I need a program in visual basic to solve the question below: -By applying Newton Raphson method,find the root of 3x-2tanx=0 given that there is a root between pie/6 and pie/3.Thank you. What have you tried by yourself.... we dont hand out programs.... we assist. Are you new to vb?? Jan 30 '08 #2

 Expert 5K+ P: 8,434 The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve. Please read the Posting Guidelines and particularly the Coursework Posting Guidelines. Then when you are ready post a new question in this thread. MODERATOR Jan 30 '08 #3

 P: 1 Hello. I am also trying to write a program that performs this equation: (f(X) = aX3 + bX2 + cX + d). I am so completely lost, but so far I have this: Expand|Select|Wrap|Line Numbers Public Class Form1       Private Sub btncalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalc.Click         Dim A As Double         Dim B As Double         Dim C As Double         Dim D As Double         Dim X As New Double         Dim I As Integer = 0         Dim Err As Decimal         Dim intCount As Integer = 0         Dim Formula As String = ((A * X ^ 3) + (B * X ^ 2) + (C * X + D)) / ((3 * A * X ^ 2) + (2 * B * X + C))           txtA.Text = A         txtB.Text = B         txtC.Text = C         txtD.Text = D               If Formula < Err Then           Else             Do While Formula >= Err                   intCount += 1               Loop             lblroot.Text = Formula         End If     End Sub End Class   I have inputs for A,B,C,D and an error limit. I'm trying to get the program to display the root (X), and the number of times it goes through the loop (the number of iterations). 1.a, b, c, and d are four constants that define the equation as shown at the top of the screen image above; X is the root of the equation; E is an error limit, typically very small (e.g., 0.000001); f(X) = aX3 + bX2 + cX + d; f(X) = 3aX2 + 2bX + c; 2.Call Xi the current estimate of X, Xi-1 the previous estimate, and Xi+1 the next (improved) estimate of X. 3.If the absolute value of Xi  Xi-1 is less than E you are done. 4.If the absolute value of Xi  Xi-1 is greater than or equal to E, then: a.Xi-1 = Xi; b.Xi+1 = Xi  f(Xi) / f(Xi) c.Xi = Xi+1 d.go back to step 3. Mar 18 '08 #4

 Expert 100+ P: 1,295 Hello. I am also trying to write a program that performs this equation: (f(X) = aX3 + bX2 + cX + d). I am so completely lost, but so far I have this: Creating a program that solves any NR is not easy, but this is a simple case, something like this should do: Expand|Select|Wrap|Line Numbers dim Res1 as double, Res2 as double dim Var1 as double, Var2 as double 'First ask the initial value     var2 = inputbox("write an initial value") 'Then evaluate the function in Res1 and the 1st Der in Res2 do     var1 = var2     Res1 = a*var1^3 + b*var1^2 + c*var1 + d     Res2 = 3*a*var1^2 + 2*var1 + c     var2 = var1 - res1/res2 loop until abs(var1 - var2)< .0000001'or any epsilon you want msgbox var2 From here im pretty sure you can make many particular cases ^.^ Mar 19 '08 #5 