Смекни!
smekni.com

Численные методы решения систем линейных уравнений (стр. 5 из 6)

End

Begin VB.Label Метка29

Caption = "Z"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 255

Left = 4920

TabIndex = 36

Top = 1080

Width = 255

End

Begin VB.Label Метка28

Caption = "Y"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 255

Left = 3000

TabIndex = 35

Top = 1080

Width = 255

End

Begin VB.Label Метка27

Caption = "X"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 1080

TabIndex = 34

Top = 1080

Width = 255

End

Begin VB.Label Метка23

Caption = "Z"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 255

Left = 4440

TabIndex = 33

Top = 3480

Width = 255

End

Begin VB.Label Метка22

Caption = "Y"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 255

Left = 3120

TabIndex = 32

Top = 3480

Width = 255

End

Begin VB.Label Метка21

Caption = "X"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 255

Left = 1800

TabIndex = 31

Top = 3480

Width = 255

End

Begin VB.Label Метка20

Caption = "А33"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 3840

TabIndex = 27

Top = 2640

Width = 375

End

Begin VB.Label Метка19

Caption = "А23"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 3840

TabIndex = 26

Top = 2040

Width = 375

End

Begin VB.Label Метка18

Caption = "А13"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 3840

TabIndex = 25

Top = 1440

Width = 375

End

Begin VB.Label Метка17

Caption = "А32"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 1920

TabIndex = 21

Top = 2640

Width = 375

End

Begin VB.Label Метка16

Caption = "А22"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 1920

TabIndex = 20

Top = 2040

Width = 375

End

Begin VB.Label Метка15

Caption = "А12"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 1920

TabIndex = 19

Top = 1440

Width = 375

End

Begin VB.Line Строка2

X1 = 0

X2 = 7800

Y1 = 3360

Y2 = 3360

End

Begin VB.Label Метка12

Alignment = 2 'Выравнивание по Центру

Caption = "Метод обратной матрицы"

BeginProperty Font

Name = "Times New Roman"

Size = 11.25

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 855

Left = 0

TabIndex = 15

Top = 5280

Width = 1095

End

Begin VB.Label Метка11

Alignment = 2 'Выравнивание по Центру

Caption = "Метод Гаусса"

BeginProperty Font

Name = "Times New Roman"

Size = 11.25

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 615

Left = 0

TabIndex = 14

Top = 4560

Width = 1095

End

Begin VB.Label Метка10

Alignment = 2 'Выравнивание по Центру

Caption = "Метод Крамера"

BeginProperty Font

Name = "Times New Roman"

Size = 11.25

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 615

Left = 0

TabIndex = 13

Top = 3840

Width = 1095

End

Begin VB.Label Метка7

Caption = "В3"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 6000

TabIndex = 6

Top = 2640

Width = 255

End

Begin VB.Label Метка6

Caption = "В2"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 6000

TabIndex = 5

Top = 2040

Width = 255

End

Begin VB.Label Метка5

Caption = "В1"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 6000

TabIndex = 4

Top = 1440

Width = 255

End

Begin VB.Label Метка4

Caption = "А31"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 0

TabIndex = 3

Top = 2640

Width = 375

End

Begin VB.Label Метка3

Caption = "А21"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 0

TabIndex = 2

Top = 2040

Width = 375

End

Begin VB.Label Метка2

Caption = "А11"

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 0

TabIndex = 1

Top = 1440

Width = 375

End

Begin VB.Label Метка1

Caption = $"frmSlay.frx":0000

BeginProperty Font

Name = "Times New Roman"

Size = 12

Charset = 204

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 855

Left = 120

TabIndex = 0

Top = 120

Width = 7575

End

End

Attribute VB_Name = "frmAriel"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Private Sub cmdClean_Click()

Dim с As Byte

с = MsgBox("Хотите очистить?", 33, "Очистка")

If с = 1 Then

txtA11.Text = ""

txtA12.Text = ""

txtA13.Text = ""

txtA21.Text = ""

txtA22.Text = ""

txtA23.Text = ""

txtA31.Text = ""

txtA32.Text = ""

txtA33.Text = ""

txtB1.Text = ""

txtB2.Text = ""

txtB3.Text = ""

txtMKX.Text = ""

txtMGX.Text = ""

txtMOMX.Text = ""

txtMKY.Text = ""

txtMGY.Text = ""

txtMOMY.Text = ""

txtMKZ.Text = ""

txtMGZ.Text = ""

txtMOMZ.Text = ""

End If

End Sub

Private Sub cmdCount_Click()

If (Val(txtA11) * Val(txtA22) * Val(txtA33) + Val(txtA12) * Val(txtA23) * Val(txtA31) + Val(txtA21) * Val(txtA32) * Val(txtA13) - Val(txtA13) * Val(txtA22) * Val(txtA31) - Val(txtA12) * Val(txtA21) * Val(txtA33) - Val(txtA23) * Val(txtA32) * Val(txtA11)) = 0 Then

Dim g As Byte

g = MsgBox("Решить данную систему методом Крамера и методом обратной матрицы невозможно", 32, "Определитель системы равен 0")

Else

ds = (Val(txtA11) * Val(txtA22) * Val(txtA33) + Val(txtA12) * Val(txtA23) * Val(txtA31) + Val(txtA21) * Val(txtA32) * Val(txtA13) - Val(txtA13) * Val(txtA22) * Val(txtA31) - Val(txtA12) * Val(txtA21) * Val(txtA33) - Val(txtA23) * Val(txtA32) * Val(txtA11))

dx = (Val(txtB1) * Val(txtA22) * Val(txtA33) + Val(txtA12) * Val(txtA23) * Val(txtB3) + Val(txtB2) * Val(txtA32) * Val(txtA13) - Val(txtA13) * Val(txtA22) * Val(txtB3) - Val(txtA12) * Val(txtB2) * Val(txtA33) - Val(txtA23) * Val(txtA32) * Val(txtB1))

dy = (Val(txtA11) * Val(txtB2) * Val(txtA33) + Val(txtB1) * Val(txtA23) * Val(txtA31) + Val(txtA21) * Val(txtB3) * Val(txtA13) - Val(txtA13) * Val(txtB2) * Val(txtA31) - Val(txtB1) * Val(txtA21) * Val(txtA33) - Val(txtA23) * Val(txtB3) * Val(txtA11))

dz = (Val(txtA11) * Val(txtA22) * Val(txtB3) + Val(txtA12) * Val(txtB2) * Val(txtA31) + Val(txtA21) * Val(txtA32) * Val(txtB1) - Val(txtB1) * Val(txtA22) * Val(txtA31) - Val(txtA12) * Val(txtA21) * Val(txtB3) - Val(txtB2) * Val(txtA32) * Val(txtA11))

txtMKX.Text = (dx / ds)

txtMKY.Text = (dy / ds)

txtMKZ.Text = (dz / ds)

txtMOMX.Text = (((Val(txtA22) * Val(txtA33) - Val(txtA23) * Val(txtA32)) / ds) * Val(txtB1) + ((Val(txtA13) * Val(txtA32) - Val(txtA12) * Val(txtA33)) / ds) * Val(txtB2) + ((Val(txtA12) * Val(txtA23) - Val(txtA13) * Val(txtA22)) / ds) * Val(txtB3))

txtMOMY.Text = (((Val(txtA23) * Val(txtA31) - Val(txtA21) * Val(txtA33)) / ds) * Val(txtB1) + ((Val(txtA11) * Val(txtA33) - Val(txtA13) * Val(txtA31)) / ds) * Val(txtB2) + ((Val(txtA13) * Val(txtA21) - Val(txtA11) * Val(txtA23)) / ds) * Val(txtB3))

txtMOMZ.Text = (((Val(txtA21) * Val(txtA32) - Val(txtA22) * Val(txtA31)) / ds) * Val(txtB1) + ((Val(txtA12) * Val(txtA31) - Val(txtA11) * Val(txtA32)) / ds) * Val(txtB2) + ((Val(txtA11) * Val(txtA22) - Val(txtA12) * Val(txtA21)) / ds) * Val(txtB3))

End If

If Val(txtA11) = 0 Then

Dim gg As Byte

gg = MsgBox("Решить данную систему методом Гаусса невозможно. Поменяйте уравнения местами, и попробуйте снова", 48, "Коэффициент при х в первом уравнении равен 0")

Else

s1 = ((Val(txtB3) * Val(txtA11)) - (Val(txtB1) * Val(txtA31)))

s2 = ((Val(txtA22) * Val(txtA11)) - (Val(txtA12) * Val(txtA21)))

s3 = ((Val(txtB2) * Val(txtA11)) - (Val(txtB1) * Val(txtA21)))

s4 = ((Val(txtA32) * Val(txtA11)) - (Val(txtA12) * Val(txtA31)))