Expectation value of Hamiltonian? Consider a particle in an infinite potential well with length $L$: $\forall x \in (0,L): V(x) = 0$ and $V(x) = \infty$ elsewhere. The wave function at time $t = 0$ is given by $$ \psi(x,0) = \begin{cases} N(x - L/2) & 0 \leq x \leq L \\ 0 & \text{elsewhere} \end{cases}$$ I determined the normalization constant as $N$ has $N = \sqrt{\frac{12}{L^3}}$. The problem is also asking me to find $$ \psi(x,0) = \sum_{n}^{\infty} c_n \psi_n(x) $$ and to determine the expansion coefficients $c_n$. I did that by using the orthonormality conditions. For the infinite potential well we know that the wave functions are given as $$\psi_n(x) = \sqrt{\frac{2}{L}} \sin(\frac{n\pi x}{L}). $$ So I used $$ c_m = \int \psi_m^*(x) \psi(x,0) dx $$ and found the expansion coefficients as $$ c_n = \begin{cases} 0 & \text{when n is odd} \\ - \frac{\sqrt{24}}{n \pi} & \text{when n is even} \end{cases}$$ I also need to find the wave function $\Psi(x,t)$ at any later time. I wrote $$ \Psi(x,t) = \sum_n c_n \psi_n(x) \exp(-iE_nt / \hbar) $$ where $$E_n = \frac{n^2 \pi^2 \hbar^2}{2mL^2} $$ for the potential well. But the final question of this problem asks me to find the expectation value of the energy. So this means I have to find $$ \langle H \rangle = \int \Psi^*(x,t) H \Psi(x,t) dx  = \int \big( \sum_m c_m \psi_m \exp(iE_mt / \hbar \big) H \big( \sum_n c_n \psi_n \exp(-iE_nt / \hbar) \big) dx $$ ? But how do I calculate this expression? Or is there some better way to find the expectation value of the energy? Griffiths textbook says (chapter two) that if $$ \Psi(x,t) = \sum_n c_n \psi_n(x) \exp(-iE_nt / \hbar) $$ then $$ \langle H \rangle = \sum_n^{\infty} E_n |c_n|^2. $$ But how do I know this series will converge? 
 A: After making edits taking Valter Moretti's corrections into account I now feel quite confident in this answer.
I have followed your calculations and they seem correct. But you certainly can't "drop the summation" as you mention in the comments. The sum reduces (with $n = 2k$) as
$$ \left<E\right> = \sum_{k=1}^{\infty} E_n |c_n|^2
   = \sum_{k=1}^{\infty} \frac{n^2 \pi^2 \hbar^2}{2mL^2} \frac{24}{n^2 \pi^2}
   = \sum_{k=1}^{\infty} \frac{12 \hbar^2}{mL^2}
   = \frac{12 \hbar^2}{mL^2} \sum_{k=1}^{\infty} 1 = \infty. $$
The fact is that the expectation value of the energy is actually infinite.
Such a situation might seem bizarre, but as professor Moretti pointed out it is actually not an impossible situation; you will never measure an infinite value of the energy. The probability $|c_n|^2$ of measuring the energy $E_n$ still goes to zero as $n$ goes to infinity. An infinite expectation value simply means that if you take many measurements and average them, the average will increase without bound. This does not break any particular physical principles.
Actually, as detailed in the answers to the question that Qmechanic referenced, infinite energy expectation values are typical of discontinuous wavefunctions such as the one in your initial condition. In fact, the coefficients $c_n$ that you have derived show that $\psi$ is discontinuous, because it ts a theorem of Fourier analysis that if $\psi$ is continuous, then there is a constant $K$ such that $|c_n| \leq K/n^2$. In this case, $c_n$ goes to zero as $1/n$, not $1/n^2$.
A: I'm glad I found this post. I was thinking about Problem 2.8 in Griffiths-Schroeter: Introduction to QM, 3rd ed., where the $\psi(x,0)$ is the characteristic function of an interval. Even though the exercise didn't ask about $<H>$, I computed it anyway just for fun, and was surprised that it didn't converge. At first I thought I made a mistake, but this make sense now.
The problem can be read here, together with a solution, though it doesn't discuss $<H>$:
https://stemjock.com/STEM%20Books/Griffiths%20QM%203e/Chapter%202/GriffithsQMCh2p8.pdf
