# Computing the gradient of the following function

Let $$f(x_1,x_2) = \frac{1}{\sqrt{x_1^2+x_2^2+1}} \left(x_1,x_2,1 \right)$$

For $i = 1,2$ we have

$$\partial_{x_i} f = \frac{1}{\sqrt{x_1^2+x_2^2+1}}\left(\partial_{x_i}x_1,\partial_{x_i}x_2,0 \right) +\frac{-x_i}{\left(x_1^2+x_2^2+1\right)^{3/2}}(x_1,x_2,1) = \frac{1}{\left(x_1^2+x_2^2+1\right)^{3/2}} \left[\left(x_1^2+x_2^2+1\right)\left(\partial_{x_i}x_1,\partial_{x_i}x_2,0\right) - x_i(x_1,x_2,1) \right]$$

The gradient of such function, after some computation I get the following matrix

$$\nabla f = \frac{1}{\left(x_1^2+x_2^2+1\right)^{3/2}} \begin{pmatrix} x_2^2+1 & - x_1x_2 & -x_1 \\ -x_1x_2 & x_1^2+1 & -x_2 \end{pmatrix}$$

Is it correct?

• the gradient is not a matrix. Maybe you mean the jacobian matrix. – Masacroso Feb 28 '18 at 15:53
• The gradient is a matrix if your function is a vector, which is my case. – user8469759 Feb 28 '18 at 15:54
• @Masacroso: tha gradient of a vector function is an standard definition in some contexts. (eres el mismo del rincon?) – yemino Feb 28 '18 at 16:03
• @Masacroso It's not my language... math.stackexchange.com/questions/156880/…, this guy calls "gradient" essentially the same thing. – user8469759 Feb 28 '18 at 16:09
• @user8469759 alright, first time I heard of it – Masacroso Feb 28 '18 at 16:12

• In definition that I know, the gradient of a vector function $f$ is a matrix which rows are the gradient of the components of $f$, so the gradient is the same matrix if $f$ is a row or a column vector. But you must to revise the definition that you are using. – yemino Feb 28 '18 at 16:02
• @yemino I saw sometimes multivariable calculus written as $xA$ instead of $Ax$, for some jacobian matrix $A$. It is rare (as rare as call "gradient" to the jacobian matrix :p) but exists. Im the same guy of the rincon. – Masacroso Feb 28 '18 at 16:16