this could be an old question to many of you but very new to me,
As I got from some theory, gradient points to the direction that helps a function f(x) increases (or ascends to a higher value)? That is why gradient represents the uphill slope of also that function.
However, what if we have the function: y = f(x) = -x, so the gradient will no more point in the steepest ascent or not as when x increases, the value of y goes down by 1.
I have 2 assumptions after spending 1 hour researching around the Internet: Maybe the phrase "the steepest ascent" just means the biggest possible change in the value of a function no matter if the output y is positive or negative if we rise x? In either way, y = -x is a decreasing function so we apply negative gradient stuff for it?
I am trying to improve my own mathematic skills, please forgive if any mistake, thank all and the best.
The gradient is indeed always the direction of steepest ascent, at least locally. To see this, use the first-order Taylor expansion of your function
$$f(x+\delta)=f(x)+\nabla f \cdot \delta + o(\delta)$$
and note that the dot product $\nabla f \cdot \delta$ is maximized by vectors $\delta$ collinear to $\nabla f$. Likewise, $\delta = -\nabla f$ will be the direction of steepest descent.
Euclidean/Riemannian structure, - that is, a dot product - is essential here: on a general manifold without a metric, or in a vector space without an inner product, there isn't a notion of the direction of steepest ascent: you can't compute length of vectors, so even if you can see the function values at some neighbouring points, you can't compute the distance between them to decide the direction that is steepest.
Now, let's look at your function $f: \mathbb R \rightarrow \mathbb R$ defined by $f(x)=-x$. We're in a one-dimensional space here, so vectors are just numbers, and there are only 2 possible directions: positive numbers are vectors pointing to the positive direction (to the right, if we use the usual axes orientation), and negative vectors point to the negative direction (to the left). The function $f(x)=-x$ takes on positive values for negative $x$ and negative values for positive $x$, so it grows right-to-left. Indeed, if we compute the gradient (which is just the derivative here), we get $\nabla f = \frac{df}{dx} = -1$ which points to the left - that is, in the direction of steepest ascent.