Dim Aa() As Variant
Dim t As Variant
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub CommandButton3_Click()
Dim x As Double
n = CDbl(TextBox7)
ReDim Preserve xe(1 To n)
ReDim Preserve ye(1 To n)
For i = 1 To n
xe(i) = InputBox("Введите x(" & CStr(i - 1) & ") =" & vbCr & "x(0)=1" & vbCr & "x(1)=3" & vbCr & "x(2)=5" & vbCr & "x(3)=7", " Ввод значений интерполяционной таблицы", 1, 5000, 8000)
Next i
For i = 1 To n
ye(i) = InputBox("Введите y(" & CStr(i - 1) & ") =" & vbCr & "y(0)=3" & vbCr & "y(1)=10" & vbCr & "y(2)=2" & vbCr & "y(3)=5", " Ввод значений интерполяционной таблицы", 1, 8000, 5000)
Next i
Label5 = "X" & " Y" & vbCr & CStr(xe(1)) & " " & CStr(ye(1)) & vbCr & CStr(xe(2)) & " " & CStr(ye(2)) & vbCr & CStr(xe(3)) & " " & CStr(ye(3)) & vbCr & CStr(xe(4)) & " " & CStr(ye(4))
End Sub
Private Sub CommandButton4_Click()
Dim x As Double
Dim nad As String
Dim ziclo As Double
n = CDbl(TextBox7)
ReDim Preserve xe(1 To n) As Double
ReDim Preserve ye(1 To n) As Double
x = CDbl(TextBox3)
'If CheckBox1 Then
'TextBox4 = Format(Kanon(x, xe, ye), "0.000")
'Else
'extBox4 = ""
'End If
If CheckBox1 Then
Call Kanon3(x, xe, ye, nad, ziclo)
TextBox4 = Format(ziclo, "0.000")
Label6 = nad
Else
TextBox4 = ""
End If
If CheckBox2 Then TextBox5 = Format(lagr(x, xe, ye), "0.000") Else TextBox5 = ""
If CheckBox3 Then TextBox6 = Format(Newtonn(x, xe, ye), "0.000") Else TextBox6 = ""
End Sub
Sub Kanon3(x As Double, xe As Variant, ye As Variant, Polinom As String, Kanon_znac As Double)
Dim xx() As Double
Dim yye() As Double
n = Application.Count(xe)
ReDim xx(1 To n, 1 To n) As Double
ReDim yye(1 To n, 1 To 1) As Double
For i = 1 To n
For j = 1 To 1
yye(i, j) = ye(i)
Next j
Next i
For i = 1 To n
For j = 1 To n
If j = 1 Then xx(i, j) = xe(i) ^ 0
If j = 2 Then xx(i, j) = xe(i) ^ 1
If j = 3 Then xx(i, j) = xe(i) ^ 2
If j = 4 Then xx(i, j) = xe(i) ^ 3
If j = 5 Then xx(i, j) = xe(i) ^ 4
If j = 6 Then xx(i, j) = xe(i) ^ 5
Next j
Next i
Kanon_znac = 0
For i = 1 To n
Kanon_znac = Kanon_znac + Application.Product(Application.Index(Application.MMult(Application.MInverse(xx), yye), i), x ^ (i - 1))
Next i
Polinom = "P3(x)="
For i = 1 To n
If Application.Product(Application.Index(Application.MMult(Application.MInverse(xx), yye), i), 1) < 0 Then
Polinom = Polinom & Format(Application.Product(Application.Index(Application.MMult(Application.MInverse(xx), yye), i), 1), "0.00")
If i = 1 Then Polinom = Polinom & ""
If i = 2 Then Polinom = Polinom & "x^1"
If i = 3 Then Polinom = Polinom & "x^2"
If i = 4 Then Polinom = Polinom & "x^3"
If i = 5 Then Polinom = Polinom & "x^4"
If i = 6 Then Polinom = Polinom & "x^5"
Else
Polinom = Polinom & "+"
Polinom = Polinom & Format(Application.Product(Application.Index(Application.MMult(Application.MInverse(xx), yye), i), 1), "0.00")
If i = 1 Then Polinom = Polinom & ""
If i = 2 Then Polinom = Polinom & "x^1"
If i = 3 Then Polinom = Polinom & "x^2"
If i = 4 Then Polinom = Polinom & "x^3"
If i = 5 Then Polinom = Polinom & "x^4"
If i = 6 Then Polinom = Polinom & "x^5"
End If
Next i
End Sub
Дата добавления: 2020-07-18; просмотров: 446;