# Do functions with the same gradient differ by a constant?

Let $$f,g:\mathbb{R}^n\to\mathbb{R}$$ be such that $$\nabla f=\nabla g$$.

I believe this implies that $$f$$ and $$g$$ only differ by a constant, like in the one-dimensional case. But I'm not sure how to prove it. If it's indeed true, can you give me a hint?

Thanks!

• As a first simplifying step, prove that if $:\mathbb R^n \to \mathbb R$ is differentiable and $\nabla h(x) = 0$ for all $x \in \mathbb R^n$, then $h$ is constant. Then let $h = f - g$. – littleO Jul 17 '20 at 19:55

## 4 Answers

[Spoiler warning, this is more than a hint. I wanted to show this method because it avoids working with components.]

First suppose that $$h:\mathbb R^n \to \mathbb R$$ is differentiable and that $$\nabla h(x) = 0$$ for all $$x \in \mathbb R^n$$. I'll prove that $$h$$ is constant. Suppose (for a contradiction) that there exist points $$a$$ and $$b$$ in $$\mathbb R^n$$ such that $$h(a) \neq h(b)$$. Let $$z:[0,1] \to \mathbb R$$ be the function defined by $$z(t) = h(a + t(b - a)).$$ Note that $$z$$ is continuous on $$[0,1]$$ and differentiable on $$(0,1)$$ and that $$z(0) \neq z(1)$$. By the mean value theorem, there exists a number $$c$$ such that $$0 < c < 1$$ and $$z'(c) = z(1) - z(0) \neq 0.$$ But, by the chain rule, $$z'(c) = \langle \nabla h(a + c(b -a)), b - a \rangle$$ which is $$0$$ because we are assuming that $$\nabla h(x) = 0$$ for all $$x$$ in $$\mathbb R^n$$. This is a contradiction. Therefore $$h$$ is constant.

Next, to solve the original problem, let $$h = f - g$$ and apply the above result.

• You don't need to assume that $h$ is differentiable: if $\nabla h=0$ then $h$ is already differentiable since its partial derivatives are continuous. – Martin Argerami Jul 18 '20 at 10:38

If $$\nabla f=\nabla g$$, then $$\frac{\partial f}{\partial x_k}=\frac{\partial g}{\partial x_k}$$ for all $$k\in\{1,\ldots,n\}$$. Thus there exists $$c_k(x_1,\ldots,x_{k-1},x_{k+1},\ldots,x_n)$$ such that $$f=g+c_k$$. And, for $$l\neq k$$, we have $$\frac{\partial c_k}{\partial x_l}=0$$ and thus $$dc_k=0$$ and $$c_k$$ is a constant. The value of $$c_k$$ then does not depend of $$k$$ since for all $$k,l$$, $$f-g=c_k=c_l$$. Thus there exists a constant $$c$$ such that $$f=g+c$$.

HINT: Integrate both sides of

$$df=\frac{\partial f}{\partial x}dx+\frac{\partial f}{\partial y}dy+\cdots= \vec{\nabla f}\cdot \vec{dl}=\vec{\nabla g}\cdot \vec{dl}=dg$$

EDIT: As pointed out by @peek-a-boo, this only works if the functions in question have an integrable derivative (so for example a sufficient condition is for $$f$$ to be $$C^1$$; i.e continuously differentiable).

• This only works if the functions in question has an integrable derivative (so for example a sufficient condition is for $f$ to be $C^1$; i.e continuously differentiable). Sooo this is not wrong (which is why I didn't downvote) but you should atleast mention that this is an extra assumption for your proof to work. – peek-a-boo Jul 17 '20 at 20:08

Yes that's correct. Solve each ($$1$$-dimensional) equation $$\partial{f}/\partial{x_i} = \partial{g}/\partial{x_i}$$