Численные методы решения прикладных задач - page 272

272
б)
Рис. 9.6. (окончание)
Код программы в редакторе Visual Basic:
Function mu(x): mu = Sin(x): End Function
Function mu_1(t): mu_1 = 0: End Function
Function mu_2(t): mu_2 = Sin(1) * Exp(-t): End Function
Function Urtem_1()
Application.Volatile (True)
Dim u(10, 20), fi(10), a(10), b(10)
h = 0.1: tau = 0.1: N = 10: M = 20
For i = 0 To 10: u(i, 0) = mu(i * h): Next i
For k = 0 To M - 1
tk = tau * k: u(0, k + 1) = mu_1(tk + tau): u(N, k + 1) = mu_2(tk + tau)
For i = 1 To N - 1
fi(i) = (2 - 2 * h ^ 2 / tau) * u(i, k) - u(i - 1, k) - u(i + 1, k)
Next i
d = 2 + 2 * h ^ 2 / tau: a(1) = 1 / d: b(1) = -(fi(1) - mu_1(tk + tau)) / d
For i = 2 To N - 2
a(i) = -1 / (a(i - 1) - d): b(i) = (fi(i) - b(i - 1)) / (a(i - 1) - d)
Next i
u(N - 1, k + 1) = (fi(N - 1) - mu_2(tk + tau) - b(N - 2)) / (a(N - 2) - d)
For i = N - 2 To 1 Step -1
u(i, k + 1) = a(i) * u(i + 1, k + 1) + b(i)
Next i
Next k
Urtem_1 = Application.Transpose(u)
EndFunction
I...,262,263,264,265,266,267,268,269,270,271 273,274,275,276,277,278,279,280,281,282,...284
Powered by FlippingBook