How to get maximum value of a function with three variables satisfying a condition? The maximum value of the function
$$f(x, y, z) = \left(x -\frac{1}{3}\right)^2 + \left(y - \frac{1}{3}\right)^2 + \left(z - \frac{1}{3}\right)^2$$
subject to the constraints-
$x + y + z = 1; x \ge 0; y \ge 0; z \ge 0$
what is the actual method to find that ? it may be simple but i dont know , please help me to understand .

This is a smooth function defined in a closed interval and as such would achieve its maximum (and minimum) on the boundary or where the gradient is $0$.  Calculus (particularly Lagrangian formulation) is an effective way to handle this.  Other ways include using a suitable substitution (if you can find one), using suitable inequalities etc. 
Here I will demonstrate the inequality way. WLOG, let $x \ge y \ge z$.  We can show that $f(1, 0, 0) - f(x, y, z) \ge 0$.
$$f(1, 0, 0) - f(x, y, z) = \frac{2}{3} - \left(x -\frac{1}{3}\right)^2 - \left(y - \frac{1}{3}\right)^2 - \left(z - \frac{1}{3}\right)^2 \\
= \frac{1}{3} + \frac{2}{3}(x+y+z) - (x^2+y^2 + z^2) = 1 - (x^2+y^2 + z^2)$$
Now $x^2 + y^2 + z^2 \le (x+y+z)^2 = 1$ completes this proof.  The maximum is $f(1, 0, 0) =\frac{2}{3}$ which is achieved on the boundary at $(x, y, z) = (1, 0, 0)$ or any permutation. 
