250
Private Sub CommandButton1_Click()
A = ActiveSheet.Cells(3, 2).Value
B = ActiveSheet.Cells(3, 4).Value
n = ActiveSheet.Cells(3, 6).Value
ActiveSheet.Range(Cells(9, 1), Cells(100, 9)).Value = ""
'Метод Эйлера простой
P = ActiveSheet.Cells(3, 8).Value
z = ActiveSheet.Cells(3, 10).Value
h = (B - A) / n
t = A
For i = 1 To n
t1 = t + h
P1 = P + h * z
z1 = z + h * Fz(t, P, z)
t = t1
P = P1
z = z1
ActiveSheet.Cells(8 + i, 1).Value = t
ActiveSheet.Cells(8 + i, 2).Value = P
ActiveSheet.Cells(8 + i, 3).Value = z
Nexti
'Метод Эйлера с усреднением
P = ActiveSheet.Cells(3, 8).Value
z = ActiveSheet.Cells(3, 10).Value
h = (B - A) / n
t = A
For i = 1 To n
tp = t + h
Pp = P + h * z
zp = z + h * Fz(t, P, z)
t1 = t + h
P1 = P + h / 2 * (z + zp)
z1 = z + h / 2 * (Fz(t, P, z) + Fz(tp, Pp, zp))
t = t1
P = P1
z = z1
ActiveSheet.Cells(8 + i, 4).Value = t
ActiveSheet.Cells(8 + i, 5).Value = P
ActiveSheet.Cells(8 + i, 6).Value = z
Nexti
'Метод Эйлера с центрированием
P = ActiveSheet.Cells(3, 8).Value
z = ActiveSheet.Cells(3, 10).Value
h = (B - A) / n
t = A
For i = 1 To n
tp = t + h / 2