Minimize length of 95% confidence interval Let $X \sim \text{Unif}(0, \theta)$ with $\theta>0$. I have showed that the quantity $\displaystyle \frac{X}{\theta}$ is pivotal so using this I am trying to find a confidence interval for $\theta$. However, I am trying to find the minimal such CI. In particular, given 
$$
P_\theta \left (a < \frac{X}{\theta} < b\right ) = 0.95
$$
find $a, b$ such that the 95%-CI for $\theta$ is minimized. Well, this amounts to saying that 
$$
F\left (\frac{x}{a} \right ) - F\left (\frac{x}{b} \right ) = \frac{x}{a} - \frac{x}{b} = 0.95
$$
if $\displaystyle \frac{x}{a}$ and $\displaystyle \frac{x}{b}$ are in the support of the pdf.
How can I take it from here and find conditions such that the 95% CI of $\theta$ is minimized? I have tried Lagrangians and other methods as well as WolframAlpha. I can't seem to find something. In particular, WolframAlpha tells me that there are no local (hence no global) maxima.
 A: Call $u = 1-\alpha$. We want to get a $1-\alpha$ confidence interval for $\theta$ (here $u=0.95$).
Our starting point, as you mention, is:
$$P_\theta \left (a < \frac{X}{\theta} < b\right ) = u$$
where $\frac{X}{\theta} \sim U[0,1]$.
Note that for $0< a < b \leq 1$ we get:
$$P_\theta \left (a < \frac{X}{\theta} < b\right ) = b-a$$
Thus our constraint for this CI to have the correct coverage is:
$$b-a=u$$
Rearranging terms, we see that the CI will be of the form:
$$\left[\frac{X}{b}, \frac{X}{a}\right]$$
Since we are looking for the shortest CI, we want to minimize $ \bigg\vert\frac{X}{b} - \frac{X}{a} \bigg\vert$ subject to $b-a = u$ (and also domain constraints on $a,b$).
Dropping the $X>0$ from the minimization (it does not affect the result), we see that we want to minimize $ \frac{|a-b|}{ab}$ subject to $b-a=u$.
i.e. also drop the numerator from the optimization since its fixed by the contraint and we just want to maximize the denominator $ab$. Also recall our constraints  $0 < a \leq 1$ and $0 < b \leq 1$ and $b=a+u$.
Plugging everything in, we see that we want to maximize: $a(a+u)=a^2+au$ subject to $0<a\leq1-u$.
It is easy to study the monotonicity of this polynomial on $(0,1-u]$ as a 2nd degree polynomial (it is increasing there), thus it must take its maximum at $a=1-u$. Then $b=1$ and thus the shortest CI for $\theta$ is:
$$\theta \in \left[X, \frac{X}{1-u}\right]$$
In particular, for $u=0.95$ we get the CI: $\theta \in [X, 20X]$.
