# Maximum under a constraint

Let $p \in \Bbb R$ and $a_1,a_2 > 0$. For $f(x,y)=a_1x+a_2y$ , show that under the constraint $x^p + y^p = 1$ it gets a maximum value of $(a_1^q+a_2^q)^{\frac{1}{q}}$ for $q=\frac{1}{1-\frac{1}{p}}$.

My attempt: using lagrange multipliers method, I have found that the only critical point is $x= \Big( \frac{a_1^q}{a_1^q+a_2^q} \Big)^{\frac{1}{p}} ,$ $y= \Big( \frac{a_2^q}{a_1^q+a_2^q} \Big)^{\frac{1}{p}}$ which yields the wanted value for $f$. My question is, how can I be sure it is a maximum? I tried another point $(1,0)$ and saw that $f$ gets a lower value, but the constraint is not a compact set, so maybe we don't get a maximum at all?

i would write $$y=(1-x^p)^{1/p}$$ then you will have $$f(x,(1-x^p)^{1/p})=a_1x+a_2(1-x^p)^{1/p}$$ and this is easier to handle also for the second derivative. you will get $$f'(x)=a_1-\frac{a_2(1-x^p)^{1/p}x^p}{x(1-x^p)}$$ and we get $$f'(x)=0$$ if $$a_1^{p/(1-p)}+a_2^{p/(1-p)}x^p=a_2^{p/(1-p)}$$