Let us name the trains as A and B. Then,

(A's speed) : (B's speed) = √b : √a = √16 : √9 = 4 : 3.