скачать (187.1 kb.)
Доступные файлы (8):
Form1.frm | |||
Form1.frx | |||
Project1.exe | |||
Project1.vbp | |||
Project1.vbw | |||
График.xls | 15kb. | 25.05.2004 12:36 | ![]() |
Отчет.Лаба №12.doc | 157kb. | 17.10.2008 00:45 | ![]() |
Отчет.Лаба №12.docx | 99kb. | 17.10.2008 00:45 | ![]() |
Отчет.Лаба №12.docx
Содержание1. Задание -3-
2. Форма -4-
3. Измененные свойства -5-
4. Текст программы -11-
5. Результаты -18-
6. Вывод -20-
Задание
Вычислить интегралы:
а) методом центральных прямоугольников.
б) методом Чебышева
1) 0,41,2dx2+0,5∙x2 2) 0.81.2sin(2x)x2dx
Форма
Измененные свойства
Form Form1
BackColor = &H0000FFFF&
Caption = "Интегрирование"
ClientHeight = 7110
ClientLeft = 60
ClientTop = 450
ClientWidth = 10185
LinkTopic = "Form1"
ScaleHeight = 7110
ScaleWidth = 10185
StartUpPosition = 3 'Windows Default
TextBox Text5
Height = 285
Left = 3360
TabIndex = 14
Text = "Введите N от 2 до 7"
Top = 120
Width = 1695
PictureBox Picture1
BackColor = &H0080FFFF&
Height = 6255
Left = 5160
ScaleHeight = 6195
ScaleWidth = 4875
TabIndex = 9
Top = 600
Width = 4935
Frame Frame1
BackColor = &H00FF80FF&
Caption = "По формуле Чебышева"
Height = 2655
Left = 120
TabIndex = 6
Top = 4200
Width = 4935
TextBox Text1
Height = 1935
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 8
Top = 600
Width = 2295
TextBox Text2
Height = 1935
Left = 2520
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 7
Top = 600
Width = 2295
Label Label6
Alignment = 2 'Center
BackColor = &H00FFFF00&
Caption = "Погрешность метода"
Height = 255
Left = 2520
TabIndex = 13
Top = 360
Width = 2295
Label Label5
Alignment = 2 'Center
BackColor = &H00FFFF00&
Caption = "Значение интеграла"
Height = 255
Left = 120
TabIndex = 12
Top = 360
Width = 2295
CommandButton Command6
Caption = "Интеграл 2"
Enabled = 0 'False
Height = 375
Left = 1920
TabIndex = 5
Top = 120
Width = 1335
CommandButton Command3
Caption = "Интеграл 1"
Enabled = 0 'False
Height = 375
Left = 120
TabIndex = 4
Top = 120
Width = 1455
CommandButton Command1
Caption = "Завершить"
Height = 375
Left = 3360
TabIndex = 1
Top = 600
Width = 1695
Frame Frame2
BackColor = &H00FF80FF&
Caption = "Метод центральных прямоугольников"
Height = 2655
Left = 120
TabIndex = 0
Top = 1560
Width = 4935
TextBox Text4
Height = 1935
Left = 2520
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 3
Top = 600
Width = 2295
TextBox Text3
Height = 1935
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top = 600
Width = 2295
Label Label4
Alignment = 2 'Center
BackColor = &H00FFFF00&
Caption = "Погрешность метода"
Height = 255
Left = 2520
TabIndex = 11
Top = 360
Width = 2295
Label Label3
Alignment = 2 'Center
BackColor = &H00FFFF00&
Caption = "Значение интеграла"
Height = 255
Left = 120
TabIndex = 10
Top = 360
Width = 2295
Image Image2
Height = 765
Left = 1920
Picture = "Form1.frx":0000
Top = 600
Width = 1320
Image Image1
Height = 765
Left = 120
Picture = "Form1.frx":34DA
Top = 600
Width = 1440
Текст программы
Dim a1 As Single, b1 As Single, a2 As Single, b2 As Single
Dim n As Integer
Dim i1 As Single, i2 As Single
Dim y1, y2 As Integer
Dim p1, p2 As Single
Dim c() As Single
Private Sub Combo2_Change()
n = Val(Combo2.Text)
Command3.Enabled = True
Command6.Enabled = True
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Picture1.Cls
Picture1.Line (0, 6100)-(4000, 6100)
Picture1.Line (4000, 6100)-(3800, 6150)
Picture1.Line (4000, 6100)-(3800, 6050)
For i = 1 To 7
Picture1.Line (i * 500, 6195)-(i * 500, 6100)
Next i
Picture1.CurrentX = 4100
Picture1.CurrentY = 6000
Picture1.Print "n"
Picture1.Line (0, 6195)-(0, 1100)
For i = 1 To 10
Picture1.Line (0, 6100 - Int(500 * i))-(100, 6100 - Int(500 * i))
Picture1.CurrentX = 100
Picture1.CurrentY = 6100 - Int(5 * i * 10 ^ 2)
Picture1.Print Format(i * 0.1, "0.#") + "%"
Next i
Text3.Text = ""
Text4.Text = ""
For i = 1 To n
s = 0
x = a1
d = (b1 - a1) / i
For j = 1 To i
s = s + (2 + 0.5 * (x + d / 2) ^ 2) ^ (-0.5) * d
x = x + d
Next j
p1 = Abs(s - i1) * 100 / s
Text3.Text = Text3.Text + Format(s, "0.###############") + Chr(13) + Chr(10)
Text4.Text = Text4.Text + Format(p1, "0.###############") + Chr(13) + Chr(10)
If i > 2 Then Picture1.Line ((i - 1) * 500, y1)-(i * 500, 6100 - Int(5 * p1 * 10 ^ 3)), RGB(255, 0, 0)
y1 = 6100 - Int(5 * p1 * 10 ^ 3)
Next i
Text1.Text = ""
Text2.Text = ""
For i = 1 To n
s = 0
For j = 1 To i
x = (a1 + b1) / 2 + c(i, j) * (b1 - a1) / 2
s = s + (b1 - a1) / i * (2 + 0.5 * x ^ 2) ^ (-0.5)
Next j
p2 = Abs(s - i1) * 100 / s
Text1.Text = Text1.Text + Format(s, "0.###############") + Chr(13) + Chr(10)
Text2.Text = Text2.Text + Format(Abs(s - i1) * 100 / s, "0.###############") + Chr(13) + Chr(10)
If i > 2 Then Picture1.Line ((i - 1) * 500, y2)-(i * 500, 6100 - Int(5 * p2 * 10 ^ 3)), RGB(0, 0, 255)
y2 = 6100 - Int(5 * p2 * 10 ^ 3)
Next i
End Sub
Private Sub Command6_Click()
Picture1.Cls
Picture1.Line (0, 6100)-(4000, 6100)
Picture1.Line (4000, 6100)-(3800, 6150)
Picture1.Line (4000, 6100)-(3800, 6050)
For i = 1 To 7
Picture1.Line (i * 500, 6195)-(i * 500, 6100)
Next i
Picture1.CurrentX = 4100
Picture1.CurrentY = 6000
Picture1.Print "n"
Picture1.Line (0, 6195)-(0, 1100)
For i = 1 To 10
Picture1.Line (0, 6100 - Int(500 * i))-(100, 6100 - Int(500 * i))
Picture1.CurrentX = 100
Picture1.CurrentY = 6100 - Int(5 * i * 10 ^ 2)
Picture1.Print Format(i * 0.1, "0.#") + "%"
Next i
Text3.Text = ""
Text4.Text = ""
For i = 1 To n
s = 0
x = a2
d = (b2 - a2) / i
For j = 1 To i
s = s + (Sin(2 * (x + d / 2)) / (x + d / 2) ^ 2) * d
x = x + d
Next j
p1 = Abs(s - i2) * 100 / s
Text3.Text = Text3.Text + Format(s, "0.###############") + Chr(13) + Chr(10)
Text4.Text = Text4.Text + Format(p1, "0.###############") + Chr(13) + Chr(10)
If i > 2 Then Picture1.Line ((i - 1) * 500, y1)-(i * 500, 6100 - Int(5 * p1 * 10 ^ 3)), RGB(255, 0, 0)
y1 = 6100 - Int(5 * p1 * 10 ^ 3)
Next i
Text1.Text = ""
Text2.Text = ""
For i = 1 To n
s = 0
For j = 1 To i
x = (a2 + b2) / 2 + c(i, j) * (b2 - a2) / 2
s = s + (b2 - a2) / i * Sin(2 * x) / x ^ 2
Next j
p2 = Abs(s - i2) * 100 / s
Text1.Text = Text1.Text + Format(s, "0.###############") + Chr(13) + Chr(10)
Text2.Text = Text2.Text + Format(p2, "0.###############") + Chr(13) + Chr(10)
If i > 2 Then Picture1.Line ((i - 1) * 500, y2)-(i * 500, 6100 - Int(5 * p2 * 10 ^ 3)), RGB(0, 0, 255)
y2 = 6100 - Int(5 * p2 * 10 ^ 3)
Next i
End Sub
Private Sub Form_Load()
i1 = 0.523449671111428
i2 = 0.377699232829646
a1 = 0.4
b1 = 1.2
a2 = 0.8
b2 = 1.2
ReDim c(7, 7)
c(2, 1) = 0.57735
c(2, 2) = -0.57735
c(3, 1) = -0.707107
c(3, 2) = 0
c(3, 3) = 0.707107
c(4, 1) = -0.794654
c(4, 2) = -0.187592
c(4, 3) = 0.187592
c(4, 4) = 0.794654
c(5, 1) = -0.832498
c(5, 2) = -0.374541
c(5, 3) = 0
c(5, 4) = 0.374541
c(5, 5) = 0.832498
c(6, 1) = -0.866247
c(6, 2) = -0.422519
c(6, 3) = -0.266635
c(6, 4) = 0.266635
c(6, 5) = 0.422519
c(6, 6) = 0.866247
c(7, 1) = -0.883862
c(7, 2) = -0.529657
c(7, 3) = -0.323912
c(7, 4) = 0
c(7, 5) = 0.323912
c(7, 6) = 0.529657
c(7, 7) = 0.883862
End Sub
Private Sub Text5_Change()
If Val(Text5.Text) > 1 And Val(Text5.Text) < 8 Then
n = Int(Text5.Text)
Command3.Enabled = True
Command6.Enabled = True
Else
Text5.Text = "Введите N от 2 до 7"
End If
End Sub
Результаты
Интеграл №1
Интеграл №2
Вывод
В данной лабораторной работе требовалось вычислить интеграл двумя методами: методом центральных прямоугольников и методом Чебышева. На мой взгляд, метод центральных прямоугольников дает достаточную точность вычисления и проще в реализации, а метод Чебышева является более точным, но он сложнее по вычислениям.
Скачать файл (187.1 kb.)