By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,745 Members | 1,897 Online
Bytes IT Community
+ 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
Share this Question
Share on Google+
4 Replies


daniel aristidou
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
  1. Public Class Form1
  2.  
  3.     Private Sub btncalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalc.Click
  4.         Dim A As Double
  5.         Dim B As Double
  6.         Dim C As Double
  7.         Dim D As Double
  8.         Dim X As New Double
  9.         Dim I As Integer = 0
  10.         Dim Err As Decimal
  11.         Dim intCount As Integer = 0
  12.         Dim Formula As String = ((A * X ^ 3) + (B * X ^ 2) + (C * X + D)) / ((3 * A * X ^ 2) + (2 * B * X + C))
  13.  
  14.         txtA.Text = A
  15.         txtB.Text = B
  16.         txtC.Text = C
  17.         txtD.Text = D
  18.  
  19.  
  20.  
  21.         If Formula < Err Then
  22.  
  23.         Else
  24.             Do While Formula >= Err
  25.  
  26.                 intCount += 1
  27.  
  28.             Loop
  29.             lblroot.Text = Formula
  30.         End If
  31.     End Sub
  32. End Class
  33.  
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

kadghar
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
  1. dim Res1 as double, Res2 as double
  2. dim Var1 as double, Var2 as double
  3. 'First ask the initial value
  4.     var2 = inputbox("write an initial value")
  5. 'Then evaluate the function in Res1 and the 1st Der in Res2
  6. do
  7.     var1 = var2
  8.     Res1 = a*var1^3 + b*var1^2 + c*var1 + d
  9.     Res2 = 3*a*var1^2 + 2*var1 + c
  10.     var2 = var1 - res1/res2
  11. loop until abs(var1 - var2)< .0000001'or any epsilon you want
  12. msgbox var2
From here im pretty sure you can make many particular cases ^.^
Mar 19 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.