# How to find gradient of $f(x)=-\sum_{i=1}^n \log x_i$

I am trying to find the gradient $\nabla f(x)\,\,$ of $\,f: \mathbb{R}^n\rightarrow\mathbb{R}$ of $$f(x)=-\sum_{i=1}^n \log x_i,$$ but I am getting stuck when it comes time to deal with the log.

I know there are several options for taking the derivative:

1) delta method, which involves basically applying the extreme value theorem. Add a small perturbation, and then isolating the parts of the function which involve an inner product of the perturbation with a function of the variable: $f(x+h)=f(x)+<\nabla f,h>+o(||h||)$ where $o(||h||)$ is a function such that the limit as h approaches 0 is zero (comes straight from the definition of differentiability);

2) vector calculus using chain rule.

Since the equation $f(x)$ is not expressed in a vector here, I figured it would be easier to do 1) via perturbation, so here's what I tried:

I try to add $h$ which is my perturbation to the vector $x$:

$f(x+h)= - \sum_{i=1}^n \log (x_i+h_i)$

But now here, there are not many options for taking the logarithm of the sum of two numbers. So, I'm wondering if maybe I can split this out into $\log (x_i) + \log(h_i)$ and just call my perturbation $log(h_i)$ instead of $h_i$?

Are there any other hints to finding the gradient of this function $f$?

• do you mean $f(x) = -\log x_1-\log x_2-...-\log x_n$? – gimusi Apr 7 '18 at 7:26
• yes, isn't that what I have above? – Hunle Apr 8 '18 at 20:45
• Yes I see, I asked only to be sure about that! – gimusi Apr 8 '18 at 20:47

## 1 Answer

Note that

$$\frac{\partial f}{\partial x_i}=-\frac 1 {x_i}$$

then

$$\Delta f = \left(-\frac 1 {x_1},-\frac 1 {x_2},...,-\frac 1 {x_n}\right)$$

• that doesn't answer my question of how to find it using the "delta method". as I said in my question. I want to find it using $f(x+h)=f(x)+<\nabla f,h>+o(||h||)$ where $o(||h||)$ is a function such that the limit as h approaches 0 is zero (comes straight from the definition of differentiability); – Hunle Apr 8 '18 at 20:46
• @Hunle I didn't catch you were asking for a specific method, since you wrote "Are there any other hints to finding the gradient of this function f?" I gave you the hint about the easiest way to find it that is of course via derivative. The definition is inportant by a theoretical point of view but it is not effective to calculate the gradient in general. – gimusi Apr 8 '18 at 20:51