This paper presents a global optimization algorithm specifically tailored for ultra-compact aspherical lens design problems for extended LED sources. The main purpose is to obtain prescribed illumination patterns, particularly the uniform illuminance distribution. This method begins by calculating the initial aspherical lens with two surfaces based on point source approximation. Then a system of polynomials is employed to fit the meridian curves of the two surfaces. In the optimization process, we use the particle swarm optimization (PSO) algorithm to automatically find the optimal polynomial coefficients when the ray tracing simulation is being performed. A series of ultra-compact aspherical lenses with dimension ratio of h / d ranging from 0.95 to 1.25 are presented, where h denotes the center height of the lens and d represents the diameter of the extended source. The results show the high efficiency and versatility of the proposed method in prescribed illumination design for extended LED sources in three-dimensional rotational symmetry geometry. Additionally, an aspherical lens is fabricated and tested, and its practical performance approaches the design.