This paper presents the pressure-volume trajectories that yield the optimal tradeoff between efficiency and power during the compression and expansion of air. These results could benefit applications such as compressed air energy storage where both high efficiency and power density are required. Earlier work established solutions for the simple case in which hA, the product of the heat transfer coefficient and heat transfer surface area, is constant. This paper extends that analysis by allowing hA to vary with air volume. Solutions to the constrained, nonlinear optimization problem are developed utilizing the method of Lagrange multipliers and Karush-Kuhn-Tucker (KKT) conditions. It is found that the optimal trajectory takes the form "fast-slow-fast" where the fast stages are adiabatic and the temperature change during the slow stage is proportional to the inverse root of the hA product. A case study predicts a 60% improvement in power over the constant-hA solution when both trajectories are run at 90% efficiency and hA = hA(V). Compared to linear-and sinusoidal-shaped trajectories, also at 90% efficiency, power gains are expected to be in the range of 500-1500%.