|   | 1 |  initial version  | 
Knowing the outcome you can do:
var('b f k')
expr = 2*b*f^2 + f^2*k - 2*b*f- f^2 - 2*f*k + b+2*f+k - 1
(expr - b*f^2).factor() + b*f^2
 Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
 
                
                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.