  For any quantity of interest in a system governed by ordinary differential
equations, it is natural to seek the largest (or smallest) long-time average
among solution trajectories, as well as the extremal trajectories themselves.
Upper bounds on time averages can be proved a priori using auxiliary functions,
the optimal choice of which is a convex optimization problem. We prove that the
problems of finding maximal trajectories and minimal auxiliary functions are
strongly dual. Thus, auxiliary functions provide arbitrarily sharp upper bounds
on time averages. Moreover, any nearly minimal auxiliary function provides
phase space volumes in which all nearly maximal trajectories are guaranteed to
lie. For polynomial equations, auxiliary functions can be constructed by
semidefinite programming, which we illustrate using the Lorenz system.
