Solution (source code)

= Solution

The endpoint integral is a Gaussian with coefficient $A=(m\omega/\hbar)\tanh(x/2)$. Therefore
$$
Z=\sqrt{\frac{m\omega}{2\pi\hbar\sinh x}}\sqrt{\frac\pi A}=\frac1{\sqrt{2\sinh x\tanh(x/2)}}=\boxed{\frac1{2\sinh(x/2)}}.
$$
It agrees with $\sum_{n\ge0}e^{-x(n+1/2)}$, tends to $1/x$ at high temperature, and to $e^{-x/2}$ at low temperature. The last limit retains the oscillator zero-point energy.