Dynamic optimization and lab on Mathematica