Text this: A polynomial approach for analysis and optimal control of switched nonlinear systems