python - Printing two values using Runge Kutta Method -
i trying print b , c code, not having luck. if correct, code should output several points step size of 0.05, not seeing it. know how print 2 values code?
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 = + 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 = + 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 = + 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 = + (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 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)
your code not have print statement, not print. try inserting like:
print 'b = {0}, c = {1}'.format(b,c)
where want print happen. python 3 add parentheses (print function now)
print('b = {0}, c = {1}'.format(b,c))
Comments
Post a Comment