A shaped beam pattern (SBP) synthesis algorithm, which obtains the desired SBP in an analytical way, is proposed. The new algorithm describes the SBP with the weighted superposition of a set of pencil beam patterns (PBPs). First, the array weight of the PBP is obtained via analytical algorithms, such as; Chebychev and Taylor, etc. Then, by computing the weights of the PBPs with the least-square method, the synthesized SBP is expressed explicitly. Different from the state-of-the-art algorithms, the proposed algorithm can obtain the desired SBP analytically, avoiding the time-consuming iteration processes. Moreover, the proposed algorithm enables the array antenna to scan the beam in different directions. Simulations with linear and planar array antennas are provided to assess the superiority and effectiveness of the proposed algorithm. This is an open access article under the terms of the Creative Commons Attribution License, which permits use, distribution and reproduction in any medium, provided the original work is properly cited.