Update Bellman algorithm (Sage implementation)