SOL: Sampling-based Optimal Linear bounding of arbitrary scalar functions