Given $S =\{ x-y \mid (x,y) \in \Bbb R , x^2+y^2=1\}$, find $\max S$ My solution:
$x^2+y^2=1$ is the equation of a circle.
Let $x-y=k$. That becomes the equation of a line. Since $(x-y) \in S$,
the point $(x,y)$ satisfies both the circle and the line equation. So we know that the graph of the circle and the line have at least $1$ intersection. Now here's the part I have a question about. I drew the graph of the circle and visualised the line equation (slope$=1$) and one can easily conclude that the maximum and minimum values of $k$ occur when the line is a tangent to the circle.
So after concluding this, rest is just calculation. ( The answer is $\sqrt2$, by the way).
My questions are:

*

*Can we prove that(without visualization) the maximum and minimum values of $k$ occur when the line is tangent to the circle?

2.Is there any other method to solve such a question?
 A: Write $\;y=\pm\sqrt{1-x^2}\;$ for both half circles (upper, with the plus sign, lower with the minus sign), then $\;f(x)=x-y=x\mp\sqrt{1-x^2}\;$ and you can use basic calculus I:
$$f'(x)=1\pm\frac x{\sqrt{1-x^2}}=0\iff x=\mp\sqrt{1-x^2}\implies x=\pm\frac1{\sqrt2}$$
and then we have the minimum $\;-\frac1{\sqrt2}-\frac1{\sqrt2}=-\sqrt2\;$ , and the maximum $\;\frac1{\sqrt2}+\frac1{\sqrt2}=\sqrt2$
A: You can do it as follows: since $x=\cos\theta$ and $y=\sin\theta$ for some $\theta\in[0,2\pi]$, then\begin{align}x-y&=\cos(\theta)-\sin(\theta)\\&=\sqrt2\left(\frac1{\sqrt2}\cos(\theta)-\frac1{\sqrt2}\sin(\theta)\right)\\&=\sqrt2\left(\cos\left(\frac\pi4\right)\cos(\theta)-\sin\left(\frac\pi4\right)\sin(\theta)\right)\\&=\sqrt2\cos\left(\frac\pi4+\theta\right)\end{align}and, since the maximum of $\cos$ is $1$, the maximum that you're after is $\sqrt2$.
A: Well,... let $y = \pm \sqrt {1-x^2}$ and let $d_1(x) = x-y= x-\sqrt{1-x^2}$ when $y\ge 0$ and $d_2(x) =x-y=  x+\sqrt{1-x^2}$ when $y < 0$.
Then $d_1'(x) = 1 -\frac 12\frac 1{\sqrt{1-x^2}}*(-2x)= 1+\frac x{\sqrt{1-x^2}}$
And $d_2'(x) = 1-\frac {x{\sqrt{1-x^2}}$.
Solving for $d_1'(x) = 0$ and $d_2'(x)=0$ we get:
$d_1'(x) = 1+\frac x{\sqrt{1-x^2}}=0$
$x = -\sqrt{1-x^2}$
$x^2 = 1-x^2; x\le 0$
$x = -\frac 1{\sqrt 2}$.
$d_1'(x) = 1-\frac x{\sqrt{1-x^2}}=0$
And $x=\sqrt{1-x^2}$
$x^2 = 1-x^2; x\ge 0$
$x = \frac 1{\sqrt 2}$. are the two critical points.
Could do second derivative test to determine if max/min but it's easier and practical to plug the values in.
At $x =-\frac 1{\sqrt 2};y \ge 0;x\le 0$ we have $x^2 + y^2 =1$ so $y=\frac 1{\sqrt 2}$ and $x-y = -\sqrt 2$.
And at $x = \frac 1{\sqrt 2}; y \le 0; x \ge 0$ we have $x^2 + y^2 =1$ so $y=-\frac 1{\sqrt 2}$ and $x-y = \sqrt 2$.
so $\sqrt 2$ is the max $x-y$ can be and $-\sqrt 2$ is the min.
