Starting from the two-mode Bose-Hubbard model, we derive an exact version of the standard Mathieu equation governing the wave function of a Josephson junction. For a finite number of particles N, we find an additional cos 2φ term in the potential. We also find that the inner product in this representation is nonlocal in φ. Our model exhibits phenomena, such as π oscillations, which are not found in the standard phase model, but have been predicted from Gross-Pitaevskii mean-field theory.