<s>[INST] Maximum and minimum function on circle Find minimum and maximum value of function
$f(x,y) = 3x+4y + |x-y|$
on circle
$$\left\{ (x,y): x^2+y^2 = 1 \right\}$$
I used polar coordinate system. So I have $x = \cos t$ and $y=\sin t$ where $ t \in [0, 2 \pi)$. 
Then i exploited definition of absolute function and i got:
$$h(t) = \begin{cases} 4 \cos t + 3 \sin t \quad t \in [0, \frac{\pi}{4}] \cup [\frac{5}{4} \pi,2 \pi) \\ 2 \cos t + 5 \sin t \quad t \in (\frac{\pi}{4}, \frac{5}{4} \pi) \end{cases}$$
Hence i received following critical points (earlier i computed first derivative):
$$\cos t = \pm \frac{4}{5} \vee \cos t = \pm \frac{2}{ \sqrt{29} }$$
Then i computed second derivative and after all i received that in $( \frac{2}{ \sqrt{29} } , \frac{5}{ \sqrt{29} }) $ is maximum equal $\sqrt{29}$ and in $(- \frac{4}{ 5 } ,- \frac{3}{5}  )$ is minimum equal $- \frac{23}{5}$.
I examined my resolution in wolfram alpha:

How you can see, this resolutions are very different than my. Even the crital points are other. Could you tell me where i have mistake?
 [/INST] We have $\frac{\partial{f}}{\partial{x}}=\frac{x-y}{\sqrt{(x-y)^2}}+3$ and $\frac{\partial{f}}{\partial{y}}=\frac{y-x}{\sqrt{(x-y)^2}}+4$, i.e., $\nabla f=(\frac{x-y}{\sqrt{(x-y)^2}}+3, \frac{y-x}{\sqrt{(x-y)^2}}+4)$. Let $\phi(x,y)=x^2+y^2$ $\Rightarrow$ $\nabla \phi= 2(x,y)$. Now, using Lagrange multipliers we have $\nabla f = \lambda \nabla \phi$, i.e., $(\frac{x-y}{\sqrt{(x-y)^2}}+3, \frac{y-x}{\sqrt{(x-y)^2}}+4) =2 \lambda(x,y)$.
With some calculations, I believe this resolves the problem.
</s>