modify derivatives to q_w and b_w