TITLE: An algorithm to generate canonical transformations: application to normal forms. AUTHOR: Alex Haro Departament de Matematica Aplicada i Analisi, Universitat de Barcelona, Gran Via 585, 08007 Barcelona, Spain E-mail: haro@mat.ub.es ABSTRACT: We describe a new method to generate symplectic diffeomorphisms. This method is based on primitive functions. We apply the algorithm to the construction of normal forms of KAM tori. A concrete application, developed in detail and implemented numerically, is normal forms near invariant circles.