Title: The upper envelope of piecewise linear functions: algorithms and applications