我正在尝试从此代码中打印 b 和 c ,但我没有任何运气。如果我是正确的,这段代码应该输出几个点,步长为 0.05,但我没有看到。有谁知道如何从此代码中打印两个值?
import math
def rK3(a, b, c, fa, fb, fc, hs):
a1 = fa(a, b, c)*hs
b1 = fb(a, b, c)*hs
c1 = fc(a, b, c)*hs
ak = a + a1*0.5
bk = b + b1*0.5
ck = c + c1*0.5
a2 = fa(ak, bk, ck)*hs
b2 = fb(ak, bk, ck)*hs
c2 = fc(ak, bk, ck)*hs
ak = a + a2*0.5
bk = b + b2*0.5
ck = c + c2*0.5
a3 = fa(ak, bk, ck)*hs
b3 = fb(ak, bk, ck)*hs
c3 = fc(ak, bk, ck)*hs
ak = a + a3
bk = b + b3
ck = c + c3
a4 = fa(ak, bk, ck)*hs
b4 = fb(ak, bk, ck)*hs
c4 = fc(ak, bk, ck)*hs
a = a + (a1 + 2*(a2 + a3) + a4)/6
b = b + (b1 + 2*(b2 + b3) + b4)/6
c = c + (c1 + 2*(c2 + c3) + c4)/6
return a, b, c
def fa2(a, b, c):
return 0.9*(1 - b*b)*a - b + math.sin(c)
def fb2(a, b, c):
return a
def fc2(a, b, c):
return 0.5
def VDP2():
a, b, c, hs = 1, 1, 0, 0.05
while (c<6):
a, b, c = rK3(a, b, c, fa2, fb2, fc2, hs)