Consider the figure of an ellipse below:

where the coordinate pair $ (x_e , y_e) $ denote a point on the positive half of the ellipse, the red stars denote the foci of the ellipse (at $x = \pm c$) , and $d$ denotes a distance centered on the foci as shown.
If we draw two lines which connect the points $(-c - \frac{d}{2}, 0)$ and $(-c+\frac{d}{2},0)$ to the point $(x_e,y_e) $ these lines will form an angle $\theta$ between them.
The question is:
For a given d, for what pair $(x_e, y_e)$ does the angle $\theta$ maximize?
My work so far
I use the law of cosines to find $\theta$ :
$$ d^2 = s_1^2 + s_2^2 - 2 \cdot s_1 \cdot s_2 \cdot cos(\theta)$$
where
$$ s_1 = \sqrt{(x_e - (-c + \frac{d}{2}))^2 + y_e^2} $$
and
$$s_2 = \sqrt{(x_e - (-c - \frac{d}{2}))^2 + y_e^2}$$
so $$cos(\theta) = \frac{s_1^2 + s_2^2 - d^2}{2 \cdot s_1 \cdot s_2}$$
I get that $s_1^2 + s_2^2 -d^2$ becomes:
$$2\cdot \left((x_e + c)^2 + y_e^2 - (\frac{d}{2})^2 \right)$$
and the full expression becomes:
$$cos(\theta) = \frac{(x_e + c)^2 + y_e^2 - (\frac{d}{2})^2}{\sqrt{\left((x_e + c - \frac{d}{2})^2 + y_e^2\right)\left((x_e + c + \frac{d}{2})^2 + y_e^2\right)}}$$
because $y_e = b \cdot \sqrt{1 - (\frac{x_e}{a})^2} $ it means that (for a constant $d$) $cos(\theta)$ is a function of only $x_e$
so finally I got:
$$\theta(x_e) = \cos^{-1}\left(\frac{(x_e + c)^2 + (b^2 \cdot (1 - (\frac{x_e}{a})^2) - (\frac{d}{2})^2}{\sqrt{\left((x_e + c - \frac{d}{2})^2 + (b^2 \cdot (1 - (\frac{x_e}{a})^2)\right)\left((x_e + c + \frac{d}{2})^2 + (b^2 \cdot (1 - (\frac{x_e}{a})^2)\right)}}\right)$$
$x_e$ goes from $[-a,a]$ and I think that $d \le 2\cdot (a - c)$ so that $-c - \frac{d}{2}$ lies within [-a,a]
Going back to the question posed, I have two sub-questions:
1) Is this the correct equation for $\theta (x_e)$ ?
2) If this equation is correct, would I just have to set the derivative equal to $0$ to find the critical points (i.e. $x_e$ which gives the maximum $\theta$) ?
Extra plot:
I plotted the above function $\theta(x)$ (with the given constants for a, b, c, and d and $\theta(x)$ is given in degrees) in python, where the red vertical lines show the x values of the foci ($x = \pm c$), and I got this:
what prompted me to ask this question is that it seems the maximum inscribed angle occurs at an x position which is not the focus $ x = - c$, even though intuitively, I would have thought it would have been at that position. Did I just mess up in the derivation of $\theta(x)$ ?


No you did not mess up - although I have not checked your calculation.
The maximum angle $\theta$ results from two possibly competing factors :
The 2nd factor favours the point which you expected. However points to the left of that are closer so they are favoured by the 1st factor. A balance between these two factors determines where $\theta$ is maximum.