in reply to Constant code
(2*aa+bb)
Is it not the case that your subroutine aa is taking +bb to be its argument rather than adding bb to the result? A deparse should confirm or refute that.