Deriving $\langle H\rangle$ from average momentum and position for a LHO Assume that we know the values of $\langle x\rangle$ and $\langle p\rangle$ for a LHO, that is in a random superposition of zeroth and first state. Derive $\langle H\rangle$.
So I tried solving this problem with writing $H=\hbar\omega (a^*a+1/2)$. We know that $a^*a= (\text{Re} a)^2+(\text{Im} a)^2$ and we can derive those from $\langle p\rangle\propto\text{Im}\langle a\rangle$. However if I average this expression for creation and annihilation operator, I end up needing $\langle p^2\rangle$ and not $\langle p\rangle^2$, which  I have (same for position).
How should I solve it?
 A: generally you can't derive $\langle H \rangle$ only from $\langle x \rangle$ and $\langle p \rangle$, because you end up needing the expectation values of $\langle x^2 \rangle$ and $\langle p^2 \rangle$, as you wrote. However, here you are given another crucial piece of information: that the state is in a superposition of the ground (zeroth) state and the first excited state.
One thing to remember is that the expectation value of the position and the momentum is zero for any eigenstate of the quantum harmonic oscillator: $\langle n | x | n\rangle = 0 = \langle n | p | n \rangle$ for any $n$. You can see that from the fact that both $x$ and $p$ are linear superpositions of $a$ and $a^{\dagger}$ and naturally $\langle n | a |n \rangle = 0 = \langle n | a^{\dagger} | n\rangle$, as these operators take an eigenstate $n$ to another eigenstate.
This means that all non-zero contributions to $\langle x \rangle$ and $\langle p \rangle$ must come from the cross terms between the ground and first excited states.
Write the state in general as $|\psi\rangle = a |0\rangle + b |1\rangle$, and get the expectation values of $\langle x \rangle$ and $\langle p \rangle$ from $a$ and $b$. Add to that the fact that $|a|^2+|b|^2=1$ and you'll get three equations for the four variables $a$ and $b$ (they are complex so each one has both real and imaginary part you need to find out). However the total phase is arbitrary so you can fix it at will, and then you have three equations for three variables, which you can easily solve and find out $\langle H \rangle = \frac{\hbar \omega}{2} |a|^2 + \frac{3\hbar\omega}{2} |b|^2$
A: The system is in a state
$$\lvert\Psi\rangle=\alpha\lvert0\rangle+\beta\lvert1\rangle\qquad \alpha,\beta\in\mathbb{C}$$
The complex constants $\alpha$ and $\beta$ are to be determined up to an arbitrary phase factor using the condition on the average values and the normalization condition
$$|\alpha|^2+|\beta|^2=1.$$
We shall express momentum and position operators in terms of ladder operators to make the math easier
$$\hat{p}=\frac{1}{i}\sqrt{\frac{\hbar m\omega}{2}}(a-a^{\dagger})\qquad \hat{x}=\sqrt{\frac{\hbar}{2m\omega}}(a+a^{\dagger})$$
By definition
\begin{align}
\langle p\rangle&=\frac{1}{i}\sqrt{\frac{\hbar m\omega}{2}}\left\{\langle 0\lvert\alpha^*+\langle1\lvert\beta^*\right\}(a-a^{\dagger})\left\{\alpha\lvert0\rangle+\beta\lvert1\rangle\right\} \\
&=\frac{1}{i}\sqrt{\frac{\hbar m\omega}{2}}\left\{\langle 0\lvert\alpha^*+\langle1\lvert\beta^*\right\}\left\{\beta\lvert0\rangle-\alpha\lvert1\rangle-\sqrt{2}\beta\lvert2\rangle\right\}\\
&=\frac{1}{i}\sqrt{\frac{\hbar m\omega}{2}}(\alpha^*\beta-\beta^*\alpha)
\end{align}
\begin{align}
\langle x\rangle&=\sqrt{\frac{\hbar}{2 m\omega}}\left\{\langle 0\lvert\alpha^*+\langle1\lvert\beta^*\right\}(a+a^{\dagger})\left\{\alpha\lvert0\rangle+\beta\lvert1\rangle\right\}\\
&=\sqrt{\frac{\hbar}{2 m\omega}}\left\{\langle 0\lvert\alpha^*+\langle1\lvert\beta^*\right\}\left\{\beta\lvert0\rangle+\alpha\lvert1\rangle+\sqrt{2}\beta\lvert2\rangle\right\}\\
&=\sqrt{\frac{\hbar}{2 m\omega}}(\alpha^*\beta+\beta^*\alpha)
\end{align}
Isolating $(\alpha^*\beta\pm\beta^*\alpha)$ and summing side by side
$$\beta\alpha^*=\frac{1}{2}\left(\sqrt{\frac{2m\omega}{\hbar}}\langle x\rangle+i\sqrt{\frac{2}{\hbar m\omega}}\langle p\rangle\right)\implies\beta=\frac{1}{2\alpha^*}\left(\sqrt{\frac{2m\omega}{\hbar}}\langle x\rangle+i\sqrt{\frac{2}{\hbar m\omega}}\langle p\rangle\right)$$
Thanks to the arbitrary phase factor, $\alpha$ can be chosen to be real i.e. $\alpha=\alpha^*$
$$\implies\beta=\frac{1}{2\alpha}\underbrace{\left(\sqrt{\frac{2m\omega}{\hbar}}\langle x\rangle+i\sqrt{\frac{2}{\hbar m\omega}}\langle p\rangle\right)}_{\eta}:=\frac{\eta}{2\alpha}. \tag{A}$$
Where the constant $\eta$ is known because it is a linear combination of the given expectation values. Imposing normalization condition
$$\alpha^2+\frac{\eta^2}{4\alpha^2}=1$$
This equation admits the solution
$$\alpha^2=\frac{1+\sqrt{1-4\eta^2}}{2} \tag{B}$$
You can choose either the positive or the negative root as it won't change the phase difference between $\alpha$ and $\beta$ and $(A)$ together with $(B)$ gives you the coefficients of the state. Now you can find that
$$\langle H\rangle=\langle\Psi\lvert H\lvert\Psi\rangle=\hbar\omega\left\{\langle 0\lvert\alpha+\langle1\lvert\beta^*\right\}\left(a^{\dagger}a+\frac{1}{2}\right)\left\{\alpha\lvert0\rangle+\beta\lvert1\rangle\right\}=\frac{\hbar \omega}{2}\alpha^2+\frac{3\hbar\omega}{2}|\beta|^2$$
