Hi guys I allready oppened another thread to know if someone can help me to solve a 3 non linear equation system. I tryed this code to make the newton raphson method to work, but insted of converging it is diverging. Can someone please help me? Thank's! - 'Cálculo do Sistema para obter os cossenos directores através do método Newton-Raphson
-
-
Dim nr, aux1, aux2, aux3, lll, mmm, nnn, ff, gg, hh, ite As Double
-
-
'Condiçăo inicial l=m=n=1
-
lll = 0.5
-
mmm = 0.5
-
nnn = 0.5
-
-
'For nr = 0 To 2
-
For ite = 0 To 20
-
-
Dim Gauss As New GaussJ
-
Gauss.InpNumEq = 3
-
-
Gauss.ManagMat(0, 0) = y(0, 0) - aux(2)
-
Gauss.ManagMat(0, 1) = y(0, 1)
-
Gauss.ManagMat(0, 2) = y(0, 2)
-
Gauss.ManagMat(1, 0) = y(1, 0)
-
Gauss.ManagMat(1, 1) = y(1, 1) - aux(2)
-
Gauss.ManagMat(1, 2) = y(1, 2)
-
Gauss.ManagMat(2, 0) = 2 * lll
-
Gauss.ManagMat(2, 1) = 2 * mmm
-
Gauss.ManagMat(2, 2) = 2 * nnn
-
-
'f(l,m,n)
-
-
ff = (y(0, 0) - aux(2)) * lll + y(0, 1) * mmm + y(0, 2) * nnn
-
gg = y(1, 0) + (y(1, 1) - aux(2)) + y(1, 2)
-
hh = lll ^ 2 + mmm ^ 2 + nnn ^ 2 - 1
-
-
Gauss.ManagCons(0) = -ff
-
Gauss.ManagCons(1) = -gg
-
Gauss.ManagCons(2) = -hh
-
-
Gauss.gaussj()
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "******x1= " & Format(Gauss.ManagCons(0), "0.0000")
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "******x2= " & Format(Gauss.ManagCons(1), "0.0000")
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "******x3= " & Format(Gauss.ManagCons(2), "0.0000")
-
-
lll = Gauss.ManagCons(0) + lll
-
mmm = Gauss.ManagCons(1) + mmm
-
nnn = Gauss.ManagCons(2) + nnn
-
-
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "l=" & lll
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "m=" & mmm
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "n=" & nnn
-
Next ite
-
' Next nr
-
3 3435 Dököll 2,364
Recognized Expert Top Contributor
Hi guys I allready oppened another thread to know if someone can help me to solve a 3 non linear equation system. I tryed this code to make the newton raphson method to work, but insted of converging it is diverging. Can someone please help me? Thank's! - 'Cálculo do Sistema para obter os cossenos directores através do método Newton-Raphson
-
-
Dim nr, aux1, aux2, aux3, lll, mmm, nnn, ff, gg, hh, ite As Double
-
-
'Condiçăo inicial l=m=n=1
-
lll = 0.5
-
mmm = 0.5
-
nnn = 0.5
-
-
'For nr = 0 To 2
-
For ite = 0 To 20
-
-
Dim Gauss As New GaussJ
-
Gauss.InpNumEq = 3
-
-
Gauss.ManagMat(0, 0) = y(0, 0) - aux(2)
-
Gauss.ManagMat(0, 1) = y(0, 1)
-
Gauss.ManagMat(0, 2) = y(0, 2)
-
Gauss.ManagMat(1, 0) = y(1, 0)
-
Gauss.ManagMat(1, 1) = y(1, 1) - aux(2)
-
Gauss.ManagMat(1, 2) = y(1, 2)
-
Gauss.ManagMat(2, 0) = 2 * lll
-
Gauss.ManagMat(2, 1) = 2 * mmm
-
Gauss.ManagMat(2, 2) = 2 * nnn
-
-
'f(l,m,n)
-
-
ff = (y(0, 0) - aux(2)) * lll + y(0, 1) * mmm + y(0, 2) * nnn
-
gg = y(1, 0) + (y(1, 1) - aux(2)) + y(1, 2)
-
hh = lll ^ 2 + mmm ^ 2 + nnn ^ 2 - 1
-
-
Gauss.ManagCons(0) = -ff
-
Gauss.ManagCons(1) = -gg
-
Gauss.ManagCons(2) = -hh
-
-
Gauss.gaussj()
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "******x1= " & Format(Gauss.ManagCons(0), "0.0000")
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "******x2= " & Format(Gauss.ManagCons(1), "0.0000")
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "******x3= " & Format(Gauss.ManagCons(2), "0.0000")
-
-
lll = Gauss.ManagCons(0) + lll
-
mmm = Gauss.ManagCons(1) + mmm
-
nnn = Gauss.ManagCons(2) + nnn
-
-
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "l=" & lll
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "m=" & mmm
-
TextBox14.Text += Environment.NewLine
-
TextBox14.Text += "n=" & nnn
-
Next ite
-
' Next nr
-
Good of you to add your code, spranto...
Not a mathematician, but in this case could explain a bit what newton raphson is and what it is supposed to do. Also, could you comment in English. This should help tackle the problem, especially if members here know what newton raphson is.
Sorry for your troubles!
kadghar 1,295
Recognized Expert Top Contributor
Hi,
I'm new here, but i've seen they dont like people to help others doing their homeworks. Anyway, i think you to use MatLab to make this with a matrix using Gauss Jordan.
Im not very familiarized with the gauss jordan functions in VB, but if your problem it's about a 3rd grade eq with NR, it could be easier to ask the user the function and the first d.
f(x) = Ax3 + Bx2 + Cx + D
f'(x) = Ex2 + Fx + G
and make the letters (A to G) the inputs for your function.
I saw you used a FOR to make 20 iterations, but i'd use a WHILE instead and some precision limit:
Public Function NR( A B... as Double) as Double
Dim Dou1 as Double '<----this is your precision
Dim Dou2 as Double '<--- this will be the value you obtain
Dim Dou3 as Double '<----this will be the former value you had
Dou1 = .000001
Dou2 = 0
Dou3 = .05
While Abs(Dou3 - Dou2) > Dou1
Dou3 = Dou2
Dou2 = Dou3 - (A*Dou3^3 + B*Dou3^2 + C*Dou3 + D) / ( E*Dou3^2 + F*Dou3^ + G)
Wend
NR = Dou2
End Function
Good Luck
Dököll 2,364
Recognized Expert Top Contributor
Hi,
I'm new here, but i've seen they dont like people to help others doing their homeworks. Anyway, i think you to use MatLab to make this with a matrix using Gauss Jordan.
Im not very familiarized with the gauss jordan functions in VB, but if your problem it's about a 3rd grade eq with NR, it could be easier to ask the user the function and the first d.
f(x) = Ax3 + Bx2 + Cx + D
f'(x) = Ex2 + Fx + G
and make the letters (A to G) the inputs for your function.
I saw you used a FOR to make 20 iterations, but i'd use a WHILE instead and some precision limit: -
-
Public Function NR( A B... as Double) as Double
-
-
Dim Dou1 as Double '<----this is your precision
-
Dim Dou2 as Double '<--- this will be the value you obtain
-
Dim Dou3 as Double '<----this will be the former value you had
-
-
Dou1 = .000001
-
Dou2 = 0
-
Dou3 = .05
-
-
While Abs(Dou3 - Dou2) > Dou1
-
Dou3 = Dou2
-
Dou2 = Dou3 - (A*Dou3^3 + B*Dou3^2 + C*Dou3 + D) / ( E*Dou3^2 + F*Dou3^ + G)
-
Wend
-
-
NR = Dou2
-
-
End Function
-
-
Good Luck
Hello, kadghar!
Nice of you to post you knowledge in this, again, I am blind here...hopefully it is helpful to spranto:-)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: moi |
last post by:
Can someone please help with this problem im having. i have to use the
newton-raphson technique to find the root of a function, in this case X^2 -
1. basically, the program has to read in values...
|
by: sekitoleko |
last post by:
c program for newton raphson algorithm for finding roots of a polynomial
|
by: JamesUmokoro |
last post by:
Please Im writing a project on mathematics here in school. Can someone help me with the source code for solving Numerical Analysis problem with Newton Raphson using Java programming? Thank you all...
|
by: kartikegarg |
last post by:
can you help me please with this problem..
i want a c program using newton raphson method for solving 18 equations...
the equations are not of degree greater than 1...
i need the program to input...
|
by: kolnit |
last post by:
Find a soln to the following eqtn by Newton-Raphson's method
e^(0.05x)+x^2=132254
Let f(x)= e^(0.05x)+x^2-132254
perform iterations until abs f(x)<10^-6
I just have no idea wt to do!!...
| |
by: dynamo |
last post by:
Hi guys,i was wondering if anyone knows the code to solve equations using the newton raphson method in matlab.Or at least the algorithm.
|
by: DDCane |
last post by:
i have made a code for finding a derivative and now im trying to use it to help me with a code for the newton raphson method:
def derivative (f,x,h):
import math
return float(1/(2*h)) *...
|
by: thiofdelux |
last post by:
I need a c++ program that uses newton raphson method to find the rooys of a function. The program would prompt to put in the degree of the ploynomial, the error bound 10^(n), and the first...
|
by: pauldepstein |
last post by:
Let double NR( double x, double(*)(const double&) f ) be the
signature of a Newton-Raphson function NR.
Here, f is a function which returns a double and accepts a const
double&. The aim of...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |