  Polynomials are widely used to represent the trajectories of states and/or
inputs. It has been shown that a polynomial can be bounded by its coefficients,
when expressed in the Bernstein basis. However, in general, the bounds provided
by the Bernstein coefficients are not tight. We propose a method for obtaining
numerical solutions to dynamic optimization problems, where a flexible
discretization is used to achieve tight polynomial bounds. The proposed method
is used to solve a constrained cart-pole swing-up optimal control problem. The
flexible discretization eliminates the conservatism of the Bernstein bounds and
enables a lower cost, in comparison with non-flexible discretizations. A
theoretical result on obtaining tight polynomial bounds with a finite
discretization is presented. In some applications with linear dynamics, the
non-convexity introduced by the flexible discretization may be a drawback.
