Solution (source code)

= Solution

The <exponential distribution> prior has rate $\lambda=1/3$ and support $\mu\geq0$, so its <prior density> is $(1/3)e^{-\mu/3}\mathbf1_{\{\mu\geq0\}}$. By <Bayes' theorem>,
$$
\boxed{p(\mu\mid x)=C\exp\!\left[-\frac12\sum_i(x_i-\mu)^2-\frac\mu3\right]
\mathbf1_{\{\mu\geq0\}}},
$$
where $C$ is a <normalizing constant> independent of $\mu$.

Completing the square gives a useful exact reference for the numerical sampling. Put
$$
m=\bar x-\frac1{3n},\qquad s=\frac1{\sqrt n}.
$$
Then this <normal mean posterior with an exponential prior> is a <normal distribution> with location $m$ and <variance> $s^2$, truncated below at zero. With $\phi$ the <standard normal distribution> density and $\Phi$ its <cumulative distribution function>,
$$
\boxed{p(\mu\mid x)=\frac{\phi((\mu-m)/s)}{s\Phi(m/s)}\mathbf1_{\{\mu\geq0\}}}.
$$
The exponential rate is $1/3$, not three; the <prior mean> is three. The support restriction must be retained in both the formula and the sampler.