Is there a better way to tidy this chuck of code? It is the Runge-Kutta 4th order with 4 ODEs
问题 def xpos(x,y,t): #dx/dt = v_x return vx def ypos(x,y,t): #dy/dt = v_y return vy def xvel(x,y,t): #dv_x/dt = -GMx/r^3 return -G*M*x/((x)**2 + (y)**2)**1.5 def yvel(x,y,t): # dv_y/dt = -GMy/r^3 return -G*M*y/((x)**2 + (y)**2)**1.5 xposk1 = h*xpos(x,y,t) yposk1 = h*ypos(x,y,t) xvelk1 = h*xvel(x,y,t) yvelk1 = h*yvel(x,y,t) xposk2 = h*xpos(x+(0.5*xposk1),y+(0.5*yposk1),t+(0.5*h)) yposk2 = h*ypos(x+(0.5*xposk1),y+(0.5*yposk1),t+(0.5*h)) xvelk2 = h*xvel(x+(0.5*xvelk1),y+(0.5*yvelk1),t+(0.5*h))