<s>[INST] Minimizing $a_1x_1^2 + a_2x_2^2$ for positive $a_i$, where $a_1x_1+a_2x_2=B$ 
Find $$\min\{a_1x_1^2 + a_2x_2^2\}$$
Where $ a_1x_1 + a_2x_2 = B$, and $a_1>0$ and $a_2>0 $. Find $x_1$ and $x_2$.

Can we do it usig AG mean inequality?
Let's say we have the problem to find the minimum value of $ x_1^2 + x_2^2 $.
From: $ (x_1 - x_2)^2 ≥0  $,
$ x_1^2 + x_2^2 ≥ 2x_1x_2 $
So the minimum value is:  $2x_1x_2 $ for $x_1=x_2$.
Can be this done in a simillar manner for the starting problem.
why cannot we put $ x^2 =a_1 x_1^2, y^2 =a_2 x_2^2$ and solve it like root mean square inequality (without generalization?) We get:
$x^2 = y^2 $
.
$ a_1 x_1^2 = a_2 x_2^2 $
but not $x_1 = x_2$?
 [/INST] Use standard algebra:
We have,
$$\begin{align}a_1x_1^2+a_2x_2^2&=a_1\left(\frac{B-a_2x_2}{a_1}\right)^2+a_2x_2^2\\
&=\frac{B^2-2Ba_2x_2+a_2^2x_2^2}{a_1}+a_2x_2^2\\
&=\left(a_2+\frac{a_2^2}{a_1}\right)x_2^2-\left(\frac{2Ba_2}{a_1}\right)x_2+\frac{B^2}{a_1}\end{align}$$
This is the quadratic polynomial. You can minimize the quadratic polynomial with the following method:
$$ax^2+bx+c=a(x-m)^2+n$$
where, $$m=-\frac{b}{2a}, ~ n=-\frac{b^2-4ac}{4a}$$

In this case, we have
$$\begin{align}a:=a_2+\frac{a_2^2}{a_1}, ~b:=-\frac{2Ba_2}{a_1} , ~c:=\frac{B^2}{a_1}\end{align}$$
Hence we get,
$$m:=\frac{B}{a_1+a_2},~ n:=\frac{B^2}{a_1+a_2}$$
Thus,
$$\begin{align}a_1x_1^2+a_2x_2^2=\left(a_2+\frac{a_2^2}{a_1}\right)\left(x_2-\frac{B}{a_1+a_2}\right)^2+\frac{B^2}{a_1+a_2}\end{align}$$

Finally, we conclude that
$$\min\left\{a_1x_1^2+a_2x_2^2 \mid a_1x_1+a_2x_2=B\right\}=\frac{B^2}{a_1+a_2}$$ which is attained at the point $x_1=x_2=B/(a_1+a_2)$.

</s>