In this instance ```F, opt = poly_from_expr(cancel(simplify(f)), f.gens[0])``` comes handy. 
Note: master also gives incorrect answer I guess.