How do I set up the differential equations for the finite length iron stick heat diffusion? Consider an iron cylinder. The heat doesn't go through the cylinder surface, but at the circular cross-section in the endpoints. The temperature of the surroundings is $15\ \mathrm{^\circ C}$. The initial temperature of the iron stick is $100\ \mathrm{^\circ C}$. How to set up the differential equation? $T(0,t)$ and $T(l,t)$ doesn't fit anymore. 
 A: So we have a cylinder of height $H$ and radius $R$:

Surrounding temperature is $T_e=15\text{ C}$ and initial, uniform temperature of the cylinder is $T_0=100\text{ C}$.
The cylinder is perfectly insulated, except for both circular ends, which lose heat through convection (only).

The go to equation for this kind of problem is Fourier's heat equation:

$$T_t=\alpha \nabla^2 T$$
Because of the geometry of the problem this equation begs for cylindrical coordinates:
$$\frac{\partial T}{\partial t}=\alpha \Big[\frac{1}{r}\frac{\partial}{\partial r}\Big(r\frac{\partial T}{\partial r}\Big)+\frac{1}{r^2}\frac{\partial^2 T}{\partial \phi^2}+\frac{\partial^2 T}{\partial x^2}\Big]$$
Due to symmetry considerations the $\phi$ term isn't needed and developing the partial derivatives, we get (using shorthand partials):
$$\frac{1}{\alpha}T_t=\frac{1}{r}T_r+T_{rr}+T_{xx}$$
Furthermore, because of the insulation there's no radial temperature gradient, so:
$$T_r=T_{rr}=0$$
So:
$$\frac{1}{\alpha}T_t=T_{xx}$$
So we're looking for a function:
$$T(x,t)$$
which describes the spatial distribution of $T$, as well as its evolution in time $t$. Such a function would also allow to calculate the heat flux through the ends of the cylinder (as a function of time).
All real-world differential equations require boundary conditions and this case is no different.
Initial condition:
$$T(x,0)=100$$
Convection at ends:
$$T_t(r,+\frac{H}{2},t)=h(T-T_e)$$
and:
$$T_t(r,-\frac{H}{2},t)=h(T-T_e)$$
where $h$ is the convection heat transfer coefficient.
It's advisable to make a small substitution:
$$u=T-T_e$$
So we have:
$$u(x,0)=85$$
$$u_t(+\frac{H}{2},t)=-hu$$
$$u_t(-\frac{H}{2},t)=-hu$$
Once $u(x,t)$ is found, we can convert it back to $T(x,t)$.
$$u=T-T_e$$
We assume (Ansatz):
$$u(x,t)=X(x)\Theta(t)$$
Inserting into the PDE we get:
$$X\Theta'=\alpha \Theta X''$$
Divide by $u(x,t)=X(x)\Theta(t)$:
$$\frac{\Theta''}{\alpha \Theta}=\frac{X''}{X}=-k^2$$
where $k$ is a Real number. So we have two ODEs:
$$\frac{\Theta''}{\alpha \Theta}=-k^2\tag{1}$$
$$\frac{X''}{X}=-k^2\tag{2}$$
$(1)$ solves to:
$$\Theta(t)=C \exp{(-k^2 \alpha t)}$$
And $(2)$ solves to:
$$X(x)=A \sin(kx)+B \cos(kx)\tag{3}$$
'All that is left to do' is determine the integration constants $A$, $B$ and $C$.
Unfortunately the BCs are of the Neumann type and thus non-homogeneous (non-zero). This generally creates an unsightly mess with no easy way from which to extricate $A$ and $B$.
Instead I'll try the much simpler case where the ends are kept at constant temperature $u=0$, so:
$$u(-\frac{H}{2},t)=u(\frac{H}{2},t)=0$$
This also means:
$$X(-\frac{H}{2})\Theta(t)=X(\frac{H}{2})\Theta(t)=0$$
Assume $\Theta(t) \neq 0$, thus:
$$X(-\frac{H}{2})=X(\frac{H}{2})=0$$
Insert into $(3)$:
$$A \sin(k\frac{H}{2})+B \cos(k\frac{H}{2})\tag{4}=0$$
$$A \sin(-k\frac{H}{2})+B \cos(-k\frac{H}{2})=0$$
From the last equation:
$$A \sin(k\frac{H}{2})-B \cos(k\frac{H}{2})=0\tag{5}$$
Now add $(4)$ to $(5)$:
$$2A\sin(k\frac{H}{2})=0$$
Assume $A \neq 0$, then:
$$\sin(k\frac{H}{2})=0$$
This happens for:
$$k\frac{H}{2}=n \pi$$
Or:
$$k=\frac{2n\pi}{H}$$
For $n=1,2,3,4,...$
With $\sin(k\frac{H}{2})=0$, then $B=0$. So we get:
$$X_n(x)=A_n\sin\Big(\frac{2n\pi x}{H}\Big)$$
And:
$$u_n(x,t)=D_n \exp{\Big[-\Big(\frac{2n\pi}{H}\Big)^2 \alpha t\Big]}\sin\Big(\frac{2n\pi x}{H}\Big)$$
Applying the superposition principle:
$$u(x,t)=\sum_{n=1}^{+\infty}D_n \exp{\Big[-\Big(\frac{2n\pi}{H}\Big)^2 \alpha t\Big]}\sin\Big(\frac{2n\pi x}{H}\Big)$$
The coefficients $D_n$ are obtained with the initial condition and the Fourier series.
For $t=0$, $u(x,0)=85$ and:
$$85=\sum_{n=1}^{+\infty}D_n \sin\Big(\frac{2n\pi x}{H}\Big)$$
Thus:
$$D_n=\frac{2}{H}\int_{-H/2}^{+H/2}85 \sin\Big(\frac{2n\pi x}{H}\Big)\text{d}x$$
