How can I convert a wave function to Dirac Notation? I am a Quantum Mechanics beginner, I have learnt wave function and Dirac Notation recently, however, I do not know how to convert wave function into the Dirac Notation. For example, how can I express the following initial system state (at time  $t=0$ ) as a superposition the energy eigenstates defined by a potential well, for the region  $0\leq x \leq a$:
$$\psi(x,0)=\sqrt{\cfrac{8}{5a}}\left(1+\cos{\cfrac{\pi x}{a}}\right)\sin{\cfrac{\pi x}{a}}$$
 A: You can write
$$
\vert \psi\rangle = \sum_n a_n \vert n\rangle\, ,\qquad n=1,2,\ldots 
$$
with
$$
a_n=\langle n\vert \psi\rangle = \int_0^a dx \langle n\vert x\rangle\langle x\vert n\rangle=\int_0^a\,dx\,
\psi_n(x)\,\psi(x)
$$
and $\langle x\vert n\rangle := \psi_n(x)$ the wavefunction for the $n$'th energy eigenstate of your problem.
A: Welcome to physics stackexchange. This general type of question has been asked before here. 
Your version of this question in particular, however, shows a slight misunderstanding, so I will make an additional comment: 
You can not generally convert from a function to a Dirac ket with respect to energy eigenstates without knowing the Hamiltonian (which defines energy eigenstates). 
Once you know the Hamiltonian and find its space of solutions, you can use an integral transformation to go from a wavefunction to a superposition of eigenstates of the Hamiltonian. If you are considering an infinite well, which has a space of solutions $\psi_n = \sin(\frac{n\pi x}{L})$ in the standard coordinate system, then expanding an arbitrary wavefunction, let's call it $\Phi(x)$, into Dirac notation is the same as doing the Fourier transformation
$$ |\Phi \rangle = c_0|\psi_0\rangle + c_1 |\psi_1\rangle + ... + c_n |\psi_n\rangle , $$
where 
$$ c_n = \int \limits_0^L \Phi(x) \sin\left(\frac{n\pi x}{L}\right) dx . $$
In Dirac notation, you represent this by saying $ | \Phi \rangle $ is the state. The overlap of the state $|\Phi\rangle$ with a state $|x\rangle$, meant to be interpreted as an eigenstate of position -- a state with definite position $x$, is
$$ \langle x | \Phi \rangle = \sqrt{\cfrac{8}{5a}}\left[1+\cos\left({\cfrac{\pi x}{a}}\right)\right]\sin\left({\cfrac{\pi x}{a}}\right) $$
(using your example), that's how you "recover the wave-function form." Some people like to write $\Phi(x) = \langle x| \Phi \rangle$. 
The expansion in terms of Hamiltonian Eigenstates is 
$$ \sum \limits_n | \psi_n \rangle \langle \psi_n | \Phi \rangle $$
Where $ \langle \psi_n | \Phi \rangle = c_i$, defined with the integral shown above.
