We wish to show how the shock position in a nozzle could becontrolled. Optimal control theory and algorithm is applied to thetransonic equation. The difficulty is that the derivative withrespect to the shock position involves a Dirac mass. The onedimensional case is solved, the two dimensional one is analyzed .