Although electric vehicles (EVs) are more advantageous compared to their internal-combustion-engine (ICE) counterparts, they have failed to gain popularity because of the current state of battery technology. Research demonstrates that an EV equipped with a multi-speed transmission can provide the desired power in more than one way, and therefore, reduce the energy consumption of the vehicle through gear-shifting. However, gear-shifting should be as swift and seamless as possible. We investigate the gear-shifting of a multi-speed transmission for EVs with optimum performance under functional constraints. After deriving the kinematics of the transmission, calculus of variations is employed to find the schedules of the angular velocities during gear-shifting for a swift, seamless operation, which leads to the optimal trajectory in the space of transmission angular velocities. To this end, we resort to polynomial transition functions in the time-domain. After comparing the results obtained with these polynomials, while considering the limitations of the power supply, it is concluded that what we dub the 3-4-5 polynomial offers the optimal performance. The corresponding input torques are also obtained, to guarantee the continuity of the angular velocity, acceleration and jerk. Results show that the proposed approach is highly encouraging for a smooth, swift gear-shifting.