How did Heisenberg come up with matrix mechanics? I have learnt that matrix mechanics came before Schroedinger's wave mechanics, however introductory quantum mechanics textbooks introduce you to wave mechanics first. The way in which the transition to matrix mechanics is made is by defining the matrix elements:
$$ H_{mn} = \int _{-\infty}^{+\infty} \psi_m^* \hat{H} \psi_n ~\mathrm dV $$
but these elements are defined using a wavefunction. How did Heisenberg (and others too) come up with matrix mechanics and what was the motivation? 
I have seen the application of matrix mechanics to angular momentum but how would I apply it to a simple system like a particle trapped in an infinite potential well without starting from the wave mechanics point of view?
 A: From the outset, there were three theoretical frameworks for QM: the Wave Mechanics of Schrödinger, the Matrix Mechanics of Heisenberg and the the abstract Bra-Ket formalism of Dirac. It's the formalism of Dirac that's standard, and which Dirac himself called Transformation Theory.
Weinberg, in his text on QM, briefly goes into how Heisenberg discovered matrix mechanics:

Heisenberg's starting point was the philosophical judgement, that a physical theory should not concern itself with things like  electron orbits in atoms that can never be observed. This is a risky assumption, but it served Heisenberg well...
Hence he fastened on the energies of atomic states, and the rates at which atoms spontaneously make radiative transitions from one state to another state, as the observables on which to base a physical theory.

According to Weinberg, Heisenberg then focused on modelling a 'particle with charge $\pm e$ that undergoes simple harmonic motion' with position vector x; he then derived a relation (equation 1.4.10) for $(dx/dt)_{nm}, x^2_{nm}$ and $x^3_{nm}$ after positing 'the simplest and most natural assumption'.
Heisenberg wasn't aware of matrices at the time, they weren't part of the tool-kit of physicists in general, and it's only when he showed his work to Max Born that Born recognised these relations as special cases of 'the well-known mathematical procedure known as matrix multiplication'.
