Derivation of temperature / entropy relation from statistical mechanics I am trying to prove that 
\begin{equation}
\frac{1}{T} := k_B\beta = \frac{\partial S}{\partial E}.
\end{equation}
I have that
\begin{equation}
E := \sum p_i E_i,
\end{equation}
the Gibbs entropy
\begin{equation}
S = -k_B \sum_i p_i \ln p_i,
\end{equation}
and by maximising this using Langrange multipliers, I derived the canonical ensemble,
\begin{equation}
p_i = \frac{e^{-\beta E_i}}{Z},
\end{equation}
where
\begin{equation}
Z = \sum_i e^{-\beta E_i}.
\end{equation}
My first equation is sometimes taken as a definition of $\beta$ but I have already defined it in my derivation of the canonical ensemble. Hence it is something I should be able to prove. First off, I can show from my definitions that
\begin{equation}
\begin{aligned}
S &= -\frac{k_B}{Z} \sum e^{-\beta E_i} \ln \left(\frac{e^{-\beta E_i}}{Z}\right) \\
&= \frac{k_B\beta}{Z} \sum E_i e^{-\beta E_i} + k_B\ln Z \\
&= k_B\beta E + k_B \ln Z.
\end{aligned}
\end{equation}
It would be dandy if I could show that $\frac{\partial \ln Z}{\partial E} = 0$ because then I'd be done. However, I go through to find that
\begin{equation}
E = \frac{1}{Z} \sum E_i e^{-\beta E_i} = -\frac{\partial \ln Z}{\partial \beta},
\end{equation}
and so
\begin{equation}
\frac{\partial E}{\partial Z} = \frac{\partial}{\partial \beta} \frac{\partial \ln Z}{\partial Z} = -Z^{-2} \frac{\partial Z}{\partial \beta} = \frac{ZE}{Z^2} = \frac{E}{Z},
\end{equation}
and then
\begin{equation}
\frac{\partial \ln Z}{\partial E} = \frac{\partial \ln Z}{\partial Z} \frac{\partial Z}{\partial E} = \frac{1}{Z} \frac{Z}{E} = \frac{1}{E},
\end{equation}
which I'm not sure is legal. However, I also find that
\begin{equation}
\frac{\partial E}{\partial \ln Z} = -\frac{\partial}{\partial \beta} \frac{\partial \ln Z}{\partial \ln Z} = 0.
\end{equation}
Where am I going wrong? I am aware of this answer which uses the Boltzmann formula for the entropy, but I haven't been able to use that to unpick my derivation. My partial derivatives should be taken at constant volume and particle number, which might have something to do with it, but I don't see how I can apply that.  
 A: I use units where $k_\mathrm{B} = 1$.
You are correct up to the point where you obtain $S =  \beta E + \log{Z}.$
Probably the most common source of confusion in thermodynamics is forgetting which variables are held fixed in partial derivatives. In particular, $$\beta = \frac{\partial S{\left(E,V,N\right)}}{\partial E}.$$
$T$ is not one of the variables being held fixed in this derivative! Indeed, if we raise $E$ without changing $V$ or $N$, we certainly expect $T$ to also rise! So we would need to apply the product rule to the first term to proceed as you desired: $$\frac{\partial(\beta E)}{\partial E} \neq \beta.$$
But I'd rather do things a bit differently. Since you have been working in the canonical ensemble, let us try to start by deriving the thermodynamics of the canonical ensemble.
Let $F \equiv - T \log{Z} = E - T S$.  We calcuate
\begin{align}
\frac{\partial{F}}{\partial T} &= - \log{Z} - T \frac{\partial \log{Z}}{\partial T} \\
&= - \log{Z} - T \frac{\partial \beta}{\partial T} \frac{\partial \log{Z}}{\partial \beta} \\
&= - \log{Z} + \beta \frac{\partial \log{Z}}{\partial \beta}.
\end{align}
Using the results you derived, we get
\begin{align}
\frac{\partial{F}}{\partial T}  =  \beta F - \beta E = -S.
\end{align}
Now we have entered the realm of thermodynamics - how do we relate the derivatives of $S$ to those of $F$? Well, keep in mind we're basically trying to get the first law of thermodynamics. So write the equivalent for the canonical free energy:
\begin{align}
\mathrm{d}F &= \left(\frac{\partial F}{\partial T}\right)_{V,N} \mathrm{d}T + \left(\frac{\partial F}{\partial V}\right)_{T,N} \mathrm{d}V + \left(\frac{\partial F}{\partial N}\right)_{T,V} \mathrm{d}N \\
&= - S  \,\mathrm{d} T + \left(\frac{\partial F}{\partial V}\right)_{T,N} \mathrm{d}V + \left(\frac{\partial F}{\partial N}\right)_{T,V} \mathrm{d}N .
\end{align} 
But we also have:
\begin{align}
F &= E - T S\\
\mathrm{d}F &=\mathrm{d}E - T \,\mathrm{d}S- S \, \mathrm{d}T,
\end{align} 
whence
\begin{align}
\mathrm{d}E &= T \, \mathrm{d}{S} + \left(\frac{\partial F}{\partial V}\right)_{T,N} \mathrm{d}V + \left(\frac{\partial F}{\partial N}\right)_{T,V} \mathrm{d}N \\
\mathrm{d}{S} &= \frac{1}{T} \mathrm{d}E - \frac{1}{T} \left(\frac{\partial F}{\partial V}\right)_{T,N} \mathrm{d}V - \frac{1}{T}  \left(\frac{\partial F}{\partial N}\right)_{T,V} \mathrm{d}N.
\end{align}
We thus read off the desired result, $$ \frac{1}{T} =\left( \frac{\partial S}{\partial E} \right)_{V, N}.$$
A: Kuma spotted my mistake by pointing out that
\begin{equation}
\frac{\partial (\beta E)}{\partial E} \neq \beta.
\end{equation}
I wanted to provide the answer in a slightly shorter way. Also setting $k_B = 1$,
\begin{equation}
\begin{aligned}
\frac{\partial S}{\partial E} &= \beta + E\frac{\partial \beta}{\partial E} + \frac{\partial \ln Z}{\partial E} \\
&= \beta + E\frac{\partial \beta}{\partial E} + \frac{\partial \ln Z}{\partial \beta}\frac{\partial \beta}{\partial E} \\
&= \beta + E\frac{\partial \beta}{\partial E} - E\frac{\partial \beta}{\partial E} \\
&= \beta.
\end{aligned}
\end{equation}
