# Usefulness of absolute value in optimization algorithms

In a course of Optimization Algorithms at university, professor said that in every algorithm the objective/object function/function cost is defined as: $$f(\bar x)=\lvert x_0 - g(\bar x)\rvert^{2}$$ where $x_0$ is the actual (or effective) requirement value the algorithm needs to reach, $\bar x$ is an attempt solution vector, $f$ defined as $f:\Bbb R \to \Bbb R$, $g$ defined the same as $f$, and $g$ could be a simulator/another function calculating the $\bar x$ vector.

My curiosity is about that absolute value.

I asked the professor what is the usefulness of that absolute value, since the power of two should turn that difference to a positive value anyway. He replied that it helps to reduce errors, and it's a matter of functional analysis (calculus IV ?), so I don't have the bases to understand it.

My question is: is that right? Is there the possibility to understand in simple mathematics why that absolute value is useful, and why I should not write simply $$f(\bar x)=( x_0 - g(\bar x) )^{2}$$ ?

I'm an italian computer engineer studying in Italy and my background are just Calculus I and II.

• Of course these are the same and you don't need any kind of background to understand this. Probably, the professor said this out of methodical considerations: namely, if your $x$ is not a scalar but, say, a vector, the analogous function will be $f(x)=||x-x_0||^2$ where $||x||$ is a vector norm, and the expression directly generalizes $|x-x_0|^2$. On the other hand, $(x-x_0)^2$ would be undefined in the vector case. – Vossler Mar 15 '16 at 14:42
• I forgot to say that $x$ and $x_0$ are vectors. I'll update my question. – Alberto Chiusole Mar 15 '16 at 14:45
• In that case, how do you define $g(x)=x^2$? – Vossler Mar 15 '16 at 14:46
• Do you mean something like: $g: \mathbb R^{n} \to \mathbb R$? – Alberto Chiusole Mar 15 '16 at 15:01
• Exactly, it should operate from $\mathbb{R}^n$ to $\mathbb{R}$. This is nothing like $g(x) = x*x$ that you can use in the scalar case. – Vossler Mar 15 '16 at 15:07