Home > Software engineering >  VB solution of equations
VB solution of equations

Time:11-01

As follows: the X1, X2, X3; And Y1, Y2, Y3
These known, solving a, b, c
With code, thank you
Y1 X1=a * * 2 + b * X1 + c
Y2=a + b * * * 2 X2 X2 + c
Y3 X3=a * * 2 + b + c * X3

CodePudding user response:

 
Option Explicit

N yuan a 'solution equation is
'Arr N yuan is saved in a matrix equation of the
Such as:
''3 x + 4 + 5 y z=26
'6 x + 7 + 9 y z=47
8 '4 x + y + z=6, 38
'the Arr data is:
'the Arr (1 to 3, 1 to 4)
'the Arr (1, 1)=3 Arr (1, 2)=4 Arr (1, 3)=5 Arr (1, 4)=26
'the Arr (2, 1)=6 Arr (2, 2)=7 Arr (2, 3)=9 Arr (2, 4)=47
'the Arr (3, 1)=4 Arr (3, 2)=8 Arr (3, 3)=6 Arr (3, 4)=38


Private Function Formulasolu (ByVal Arr, ByVal n As Long) As a Double ()
Dim As Long I
Dim j As Long
Dim dbTop As Double
Dim dbButtom As Double

Dim Index As Long
For the Index=1 To n
For I=1 To n
If I & lt;> The Index Then
DbTop=Arr (Index, Index)
DbButtom=Arr (I, Index)
For j=1 To n + 1
Arr (I, j)=Arr (I, j) * dbTop - Arr (j) Index, * dbButtom
Next
End the If
Next
Next

For I=1 To n
Arr (I, n + 1)=Arr (I, n + 1)/Arr (I, I)
Arr (I, I)=1
Next


Dim Formul () As a Double
ReDim Formul (n) As a Double

For I=1 To 3
Formul (I)=Arr (I, n + 1)
Next

Formulasolu=Formul

End the Function

Private Sub Command1_Click ()


Dim Arr (1 To 3, 1 To 4)
Arr (1, 1)=3
Arr (1, 2)=4
Arr (1, 3)=5
Arr (1, 4)=26

Arr (2, 1)=6
Arr (2, 2)=7
Arr (2, 3)=9
Arr (2, 4)=47

Arr (3, 1)=4
Arr (3, 2)=8
Arr (3, 3)=6
Arr (3, 4)=38


Dim solu () As a Double

Solu=Formulasolu (Arr, 3)

Dim As Long I
For I=1 To UBound (solu)
MsgBox "the first" & amp; I & amp; "A solution is:" & amp; Solu (I)
Next

End Sub

CodePudding user response:

When the X1=0, X2=1, 2 X3=
Y1=770, Y2=251, Y3=808
A spill

CodePudding user response:

Tell from the algorithm, using determinant equation,
  • Related