Smallest ellipsoid containing a box I am facing the following optimization problem.

Let us consider a $d$-dimensional box, $\mathcal{B} = \{ x \in \mathbf{R^d} \mid \forall i = \{1, \dots, d\}, |x_i| \le a_i \}$, for a given vector $a \in \mathbf{R^d}$ with positive components.
Is there any algebraic expression for the smallest ellipsoid that contains the box?
Formally, if the ellipsoid is represented by a positive semi-definite matrix $\Gamma$,  we want to find an algebraic solution for the following problem.
\begin{equation}\tag{$\mathcal{P}$}
    \begin{array}{cc}
         \text{minimise} & f(\Gamma)\\
         \text{subject to} &  \forall x \in \mathcal{B},\, x^T \Gamma^{-1} x \le 1
    \end{array}
\end{equation}
where $f$ is some function characterizing the size of the ellipsoid.

I am interesting in two particular cases:

*

*$f(\Gamma) = \det \Gamma$ which is proportional to the volume of the ellipsoid;

*$f(\Gamma) = \text{tr } \Gamma$ which is the sum of eigen-values.


From a numerical point of view, this is an easy problem, the Löwner-John ellipsoid problem (https://en.wikipedia.org/wiki/John_ellipsoid) which can be solved using SDP. I am looking for an algebraic solution.
I started by reducing the constraints to the $2^d$ "corners" of the box (since it is a convex set), I found that the matrix $\sqrt d \text{ diag } a$ is a good candidate, but I cannot conclude to a proper proof.
I'm sure this is a well studied problem, could you provide me with some hint toward the solution or a reference?
Another, open question, is there any other function $f$ that might be interesting to characterize the volume of the ellipsoid?
 A: Short answer:
If $f(\Gamma) = \text{tr }\Gamma$, then $\Gamma^* = \sum_{k = 1}^d a_i\text{ diag}(a)$.
If $f(\Gamma) = \det\Gamma$, then $\Gamma^* = d\text{ diag}(a^2)$.
Long answer:
Since the box is a convex set, the constraints can be relaxed to the $2^{d}$ corners of the box $x_i = (\pm a_1, \dots, \pm a_d)$. (Actually, we could have only considered half of them since $x_i$ and $-x_i$ generate the same constraint.)
The problem becomes:
\begin{equation}\tag{$\mathcal{P_1}$}
    \begin{array}{cc}
         \text{minimise} & f(\Gamma)\\
         \text{subject to} &  \forall i \in \{1, \dots, 2^d\},\, x_i^T \Gamma^{-1} x_i \le 1
    \end{array}
\end{equation}
Now, let us introduce the Lagrangian $\mathcal L$ of Problem $(\mathcal P_1)$.
\begin{equation}
  \mathcal{L}(\Gamma, \lambda) = f(\Gamma) +\sum_{i} \lambda_i \left(x_i^T \Gamma^{-1} x_i - 1\right)
\end{equation}
The differenciation of the Lagrangian w.r.t. $\Gamma$ gives:
\begin{equation}
  \nabla_\Gamma\mathcal{L}(\Gamma, \lambda) = \nabla_\Gamma f(\Gamma) - \Gamma^{-1}\sum_{i} \lambda_i x_i x_i^T \Gamma^{-1}
\end{equation}
To conclude, we need to know the expression of $f$, to create the dual function:
\begin{equation}
  g(\lambda) =\min_{\Gamma}\mathcal{L}(\Gamma, \lambda)
\end{equation}
For the trace:
We consider here, $f = f_1 = \text{tr}$.
The derivate of $f$ is $\nabla_\Gamma {f_1}(\Gamma) = I_d$, therefore the argmin over $\Gamma$ of $\mathcal L$ is $\Gamma^*(\lambda) =(\sum_i \lambda_i x_i x_i^T)^{1/2}$. Furthermore, the dual function becomes $g$:
\begin{equation}
  g(\lambda) = f(\Gamma^*(\lambda)) + \sum_i\lambda_i\left(x_i^T (\sum_j \lambda_j x_j x_j^T)^{-1/2}x_i -1\right)
\end{equation}
We verify that with $\lambda^*_i = 2^{-d} \sum_{k = 1}^d a_i$, and $\Gamma^* = \sum_{k = 1}^d a_i\text{ diag}(a)$, $f_1(\Gamma^*)=g(\lambda^*)$.
For the determinent:
We consider here, $f = f_2 = \log\det$ (w.l.o.g. since the logarithm is increasing).
The derivate of $f$ is $\nabla_\Gamma {f_2}(\Gamma) = \Gamma^{-1}$, therefore the argmin over $\Gamma$ of $\mathcal L$ is $\Gamma^*(\lambda) =\sum_i \lambda_i x_i x_i^T$. Furthermore, the dual function becomes $g$:
\begin{equation}
  g(\lambda) = f(\Gamma^*(\lambda)) + \sum_i\lambda_i\left(x_i^T (\sum_j \lambda_j x_j x_j^T)^{-1}x_i -1\right)
\end{equation}
We verify that with $\lambda^*_i = 2^{-d} d$, and $\Gamma^* = d\text{ diag}(a^2)$, $f_1(\Gamma^*)=g(\lambda^*)$ (where $a$ is the vector composed by the $a_i^2$).
