# Intuition for gradient when you only have one variable?

I am learning about gradient. I understand how gradient is a vector that represents the sum of the rates of change for each component variable of a function. I am able to follow the Khan Academy video showing the gradient of f(x,y). I am also able to imagine (if not visualize) what gradient would be if you had more variables. But what if you only have one variable? Like for the function $f(x) = x^2$ Do you just have a one dimensional vector? What would it look like in the case of $f(x) = x^2$?

• A one dimensional vector is just a real number. The gradient of $f$ would just be its derivative, $2x$. In fact, you should really view the derivative as a special case of the gradient, and if you know some linear algebra, you should view the gradient as a special case of the Jacobian matrix. Jun 6, 2015 at 5:36

In $n$ dimensions, $\nabla$ is the operator $$\nabla = \left(\frac{\partial}{\partial x_1},\cdots,\frac{\partial}{\partial x_n}\right)$$that acts on a differentiable function $f: \Bbb R^n \to \Bbb R$ producing: $$\nabla f = \left(\frac{\partial f}{\partial x_1},\cdots,\frac{\partial f}{\partial x_n}\right).$$Make $n= 1$. So: $$\nabla = \left( \frac{\partial}{\partial x}\right) = \left( \frac{\rm d}{{\rm d}x}\right) = \frac{\rm d}{{\rm d}x},$$ since we identify $1 \times 1$ matrices with numbers. If $f(x) = x^2$, we have: $$\nabla f = 2x = f'(x).$$
• There's a formality that seems off to me. When writing the gradient as a vector, aren't there implied unit vectors with each of the components? Thus, when reducing to one dimension, shouldn't it be $\hat{i}d/dx$, not $d/dx$? That is to say, $(d/dx) \neq d/dx$, but rather $(d/dx) = \hat{i}d/dx$, just as $(\partial/\partial x+\partial/\partial y) = \hat{i}\partial/\partial x+\hat{j}\partial/\partial y$. Otherwise we would have a vector equal to a scalar. Nov 15, 2020 at 3:28
• Yes. The real line $\Bbb R$ is a smooth manifold and for every $x \in \Bbb R$ one has $T_x\Bbb R \cong \Bbb R$. But of course I wouldn't say this in the answer, given OP's background (at the time). Nov 15, 2020 at 3:30
• Or, you can say that including $\hat{i}$ or not is explicitly describing the identification between numbers and $1\times 1$ matrices, as in the original answer. Nov 15, 2020 at 3:32
Well, you do have a one dimensional vector since if you think about it that would really just be a scalar. In particular $\frac{\partial f}{\partial x}$ is just $\frac{\text{d}f}{\text{d}x}$ in the one-variable case, so your gradient is just a derivative! So then $$\nabla x^2 = \frac{\text{d}}{\text{d}x}x^2 = 2x.$$