Several recent experiments have demonstrated the promise of atomic ensembles for quantum teleportation and quantum memory. In these cases, the collective internal state of the atoms is well described by continuous variables corresponding to the operators
X1,P1 and the interaction with the optical field
(X2,P2) by a quadratic Hamiltonian
X1X2. We show how this interaction can be used optimally to create entanglement and squeezing. We derive conditions for the efficient simulation of quadratic Hamiltonians and the engineering of all Gaussian operations and states.