maximum inscribed angle within an ellipse 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)$ ?
 A: This problem has a simple geometric interpretation. The locus of points within the upper half-plane at which the segment of width $2d$ is subtended by an angle $\theta$, is a circular arc having the same endpoints as that segment, thus with its center on the perpendicular axis of the segment. The larger is the radius, the smaller is $\theta$. Hence the maximum value of $\theta$ corresponds to the smallest such circle intersecting the ellipse, with its center on the perpendicular axis of the segment (and in the upper half plane) and internally touching the ellipse.
A quick sketch made with GeoGebra, with $a=1$, $b=1/2$, $d=(2-\sqrt3)/4$, gives a maximum angle of about $38°$, corresponding to $x_e\approx-0.96$, which is in good agreement with your graph.

EDIT.
The above geometric setting can also lead to a quantitative result. If we parameterise point $E=(a\cos t,b\sin t)$ then a normal vector to the ellipse at $E$ is ${\mathbf n}=(b\cos t,a\sin t)$, and we can write: $C=E+s{\mathbf n}$.
Parameter $s$ can then be found from $x_C=-c$ and to find $t$ we can write the equation $CE^2=CD^2$, where $D=(-c-d,0)$ is an endpoint of the given segment.
The resulting equation for $x=\cos t=x_E/a$ is quite simple:
$$
e^2x^3-(1+2e^2-d^2/a^2)x-2e=0,
$$
where $e=c/a$ is the ellipse eccentricity. Solving this with the given values ($a=1$, $d=(2-\sqrt3)/4$, $e=\sqrt3/2$) gives $x\approx -0.959788$ and $\theta=\arctan(d/y_C)\approx 38.0735$.
EDIT 2.
I realised only after writing my answer that I gave the given segment a width of $2d$, whereas at the beginning of the question its width is named $d$. And in computing numerical results I used a value for $d$ which is double of that given in the question.
A: No you did not mess up - although I have not checked your calculation.
The maximum angle $\theta$ results from two possibly competing factors :


*

*For a fixed direction of the point $E(x_e, y_e)$ from the focus $C$, angle $\theta$ is largest when the distance $EC$ is smallest. 

*For a fixed distance $EC$, angle $\theta$ is largest when the direction of $E$ from $C$ is perpendicular to the axis on which $d$ lies. 


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.
