Text this: Duality for nonconvex approximation and optimization