Question statement : Assume $f$ is a scalar field function differentiable at each point of an n-ball $B(a)$ . If $f(x) \leq f(a) \ \ \forall \ x $ in an open ball $B(a)$ , then prove that $\nabla f(a) = 0$
My try : $f(a+he_i)-f(a)\leq0$ where $e_i$ is a unit coordinate vector. Now I divide both sides by $h>0$ and take limit $\lim_{h\to 0} \frac{f(a+he_i)-f(a)}{h}\leq0$ which gives $\frac{\partial f}{\partial x_i}\leq0$ at $a$. Doing the same thing, but now dividing both sides by $h<0$ and take limit $\lim_{h\to 0} \frac{f(a+he_i)-f(a)}{h}\geq0$ which gives $\frac{\partial f}{\partial x_i}\geq0$ at $a$. Thus $\frac{\partial f}{\partial x_i}=0$ at $a$ for all $x_i, \ i \in {1,2,...n}$. Thus $\nabla f(a) = 0$.
I have no clue as to whether this "weird" method of mine is correct or not. Someone please guide.
Your proof is fine. Alternatively, if you know the connection between the directional derivative and the gradient $$ \nabla f(a) \cdot v = \nabla_v f(a) = \lim_{h \to 0} \frac{f(a+hv)-f(a)}{h} $$ then you can set $v = \nabla f(a)$ and conclude that $$ \Vert \nabla f(a) \Vert^2 = \lim_{h \to 0+} \frac{f(a+h \nabla f(a))-f(a)}{h} \le 0 \, . $$