The documentation for lbfgs is incomplete and does not explain how to pass a function as an argument, nor does it include an example of this.
I have attached a patch that explains that a function (and its gradient) can be supplied, and I have altered the last example so the the function and its gradient are passed as such, not as expressions, as in the current documentation.
Fixed/patch applied in commit 0f5708c.