A method for analytically studying sound focusing in inhomogeneous waveguides is presented. From the viewpoint of acquiring the maximum acoustic pressure at an arbitrary position with normalized energy flux injection, optimal incident waves can be derived based on the multimodal admittance method. The method involves two steps. The first step is to expand the wave solution onto a complete orthogonal basis set so that the Helmholtz equation can be transformed into two sets of first-order coupled differential equations in the modal domain. The second step is to solve the coupled equations numerically by introducing admittance matrices and propagators, which can be used to derive reflection matrices and transmission matrices. Using the multimodal admittance method, one can circumvent the contamination caused by exponentially diverging evanescent modes and acquire stable wave solutions. Then the mapping between the acoustic pressure at an arbitrary position and that of the incident wave can be constructed, and this mapping changes the problem of wave focusing into solving the extrema of inner products in Hilbert space. The optimal incident waves that generate wave focusing at an arbitrary position can be readily computed together with the corresponding wave solutions. In this paper, we study the sound focusing in waveguides with varying cross-sections, scatterers and sound-speed profiles. The results show that the optimal incident waves will take full advantage of wave scattering caused by the boundaries and inhomogeneities during propagation to achieve the maximum pressure at foci, leading to good single-point and multi-point sound focusing performance. In addition, we find when injecting the spatially sampled optimal incident waves or the optimal incident waves with random perturbations, the resultant wave focusing phenomena will be still apparent. The focusing behaviors are highly robust to the perturbations of the moduli of the incident waves and slightly less robust to that of the arguments of the incident waves. Our method is also available for analyzing wave focusing in other kinds of inhomogeneous waveguides. We believe that our research can provide guidance on designing acoustic lenses or metamaterials to focus sound waves in complex media, and can offer inspiration in wave communications, imagings and non-destructive testing.