# Jacky L's question at Yahoo! Answers regarding minimizing a sum of squares

Staff member

#### MarkFL

Staff member
Hello Jacky L,

Let's let one number be $x$ and the other be $y$. The expression we want to minimize, our objective function is:

$$\displaystyle f(x,y)=x^2+y^2$$

subject to the constraint:

$$\displaystyle g(x,y)=x+y-k=0$$

Now, using Lagrange multipliers, we obtain the system:

$$\displaystyle 2x=\lambda$$

$$\displaystyle 2y=\lambda$$

which implies:

$$\displaystyle x=y$$

and substitution into the constraint tells us:

$$\displaystyle x=y=\frac{k}{2}$$

which means there is one extremum for the objective function at:

$$\displaystyle f\left(\frac{k}{2},\frac{k}{2} \right)=\frac{1}{2}k^2$$

We may verify this is the minimum by observing:

$$\displaystyle f(0,k)=f(k,0)=k^2$$

We could also proceed by using:

$$\displaystyle y=k-x$$ and so:

$$\displaystyle f(x)=x^2+(k-x)^2=2x^2-2kx+k^2$$

Since $f(x)$ is a quadratic, we may simply find the axis of symmetry to determine the critical value:

$$\displaystyle x=-\frac{-2k}{2\cdot2}=\frac{k}{2}$$

Since the parabola opens upwards, we know the vertex is the global minimum.

If you are to use the calculus to determine the critical value, we would begin by differentiating with respect to $x$, and equating this to zero, and solving for $x$ and this will reveal the critical value:

$$\displaystyle f'(x)=4x-2=0\,\therefore\,x=\frac{k}{2}$$

Using the second derivative test, we find:

$$\displaystyle f''(x)=4>0$$

Hence the extremum at the critical value is a minimum, and so:

$$\displaystyle f_{\text{min}}=f\left(\frac{k}{2} \right)=\frac{1}{2}k^2$$

To Jacky L, and any other guests viewing this topic, I invite and encourage you to post other optimization questions in our Calculus forum.

Best Regards,

Mark.