SUMMARYIn this paper, the so-called 'continuous adjoint-direct approach' is used within the truncated Newton algorithm for the optimization of aerodynamic shapes, using the Euler equations. It is known that the direct differentiation (DD) of the flow equations with respect to the design variables, followed by the adjoint approach, is the best way to compute the exact matrix, for use along with the Newton optimization method. In contrast to this, in this paper, the adjoint approach followed by the DD of both the flow and adjoint equations (i.e. the other way round) is proved to be the most efficient way to compute the product of the Hessian matrix with any vector required by the truncated Newton algorithm, in which the Newton equations are solved iteratively by means of the conjugate gradient (CG) method. Using numerical experiments, it is demonstrated that just a few CG steps per Newton iteration are enough. Considering that the cost of solving either the adjoint or the DD equations is approximately equal to that of solving the flow equations, the cost per Newton iteration scales linearly with the (small) number of CG steps, rather than the (much higher, in large-scale problems) number of design variables. By doing so, the curse of dimensionality is alleviated, as shown in a number of applications related to the inverse design of ducts or cascade airfoils for inviscid flows.