Mathematical modeling and optimal control of carbon dioxide emissions from energy sector