General convex relaxations of implicit functions and inverse functions