def RK4update(alpha_old, omega_r, omega_d, chi, kappa, epsilon, dt):
    """Update the resonator field in each timestep using Runge-Kutta-4."""
    alpha_0_old, alpha_1_old = alpha_old
    alpha_0_dot = lambda a: -1j*(omega_r - chi - omega_d)*a - kappa*a/2 - 1j*epsilon
    alpha_1_dot = lambda a: -1j*(omega_r + chi - omega_d)*a - kappa*a/2 - 1j*epsilon
    
    k0_1 = alpha_0_dot(alpha_0_old); k0_2 = alpha_0_dot(alpha_0_old + dt*k0_1/2);
    k0_3 = alpha_0_dot(alpha_0_old + dt*k0_2/2); k0_4 = alpha_0_dot(alpha_0_old + dt*k0_3);
    
    k1_1 = alpha_1_dot(alpha_1_old); k1_2 = alpha_1_dot(alpha_1_old + dt*k1_1/2);
    k1_3 = alpha_1_dot(alpha_1_old + dt*k1_2/2); k1_4 = alpha_1_dot(alpha_1_old + dt*k1_3);
    
    alpha_0_new = alpha_0_old + dt*(k0_1 + 2*k0_2 + 2*k0_3 + k0_4)/6
    alpha_1_new = alpha_1_old + dt*(k1_1 + 2*k1_2 + 2*k1_3 + k1_4)/6
    
    return [alpha_0_new, alpha_1_new]