finding the point on the unit sphere which maximizes cosine similarity from a fixed point I'm new here and English is not my native language.
My question is as follows:
Let $a,b\in R^d$ be two fixed points. let $\theta:S_1 (a) \rightarrow R$ (i.e. the unit sphere arround $a$ ) be the function defined by: $$\theta(x) =  arccos(\frac{<b,x>}{||b||\cdot||x||})  $$
Now If I'm not mistaken it is valid by the Cauchy Schwartz ineq to write $\theta:S_1 (a) \rightarrow [0,\pi]$ since $\theta(x) \in [-1,1]$.
I would like to find the point on the sphere that maximizes $\theta$ .
I have tried taking the derivative and approaching the problem with Lagrange multipliers but failed.
Some assumptions:

*

*Assume $a,b$ are far. i.e. $||a-b|| >> 1$.

*I need this for practical reasons, thus I really do not care if it is at some point not differentiable or the formula does not work for specific $a$ or $b$ because I assume the probability of getting specific points is practically zero.

Thanks in advance!
 A: I assume that you are looking for a vector in the same direction as $b$ (most "similar") if you can find one, not a vector in the opposite direction from $b,$ despite ambiguities in the question. That is, $\theta(x)$ is the angle between the position vectors of $b$ and $x$ and you want $\theta(x) = 0$ if possible, and otherwise you want the minimum (not maximize) $\theta(x).$
If $a$ is very close to the origin the sphere completely surrounds the origin and there are vectors $x$ in any direction you want.
If $a$ is far from the origin, the vectors $x$ are distributed over all directions from the vertex of a single cone.
If the vector $b$ points inside that cone you always have an $x$ in the exact same direction; otherwise there is exactly one direction along the surface of the cone that is closet to $b.$
The condition $\lVert a - b\rVert \gg 1$
tells me only that one of the vectors $a$ or $b$ is large, not that $a$ in particular must be large, so I consider all cases for the magnitude of $a.$
Moreover, $\lVert a - b\rVert \gg 1$ tells us nothing about the angle between $a$ and $b.$
All we need from $b$ is its direction, not magnitude, so the condition
$\lVert a - b\rVert \gg 1$ doesn't restrict the answer at all.
If $\lVert a\rVert < 1$ then the origin is inside the sphere and there will always be an $x$ that is parallel to $b$ and that is the answer.
Let $\phi$ be the angle between $a$ and $b.$
If $\lVert a\rVert = 1$ (the origin is on the surface of the sphere)
and $\phi < \frac\pi2$ then there will always be an $x$ that is parallel to $b$ and that is the answer.
But if $\lVert a\rVert = 1$ and $\phi \geq \frac\pi2$ there is no unique solution for $x,$ only a sequence of vectors $x$ converging to zero such that $\theta(x)$ converges to $\phi - \frac\pi2.$
If $\lVert a\rVert > 1$ and $\lVert a\rVert \sin\phi \leq 1$ then the line through the origin in the direction of $b$ intersects the sphere at least once, and either intersection is a solution.
If $\lVert a\rVert > 1$ and $\lVert a\rVert \sin\phi > 1$
then the line through the origin in the direction of $b$ does not intersect the sphere. Take the plane through the origin that contains $a$ and $b$.
That plane intersects the sphere in a circle.
Take a tangent from the origin to that circle,
specifically the tangent that has the smaller angle with $b.$
Let $x$ be the tangent point.
