Let the function $f: U \subseteq \mathbb{R}^n \rightarrow \mathbb{R}$ be differentiable on open set $U$. Let $x,y \in U$ be such that the line segment $[x,y] \subset U$. Define the function $g : [0,1]\rightarrow \mathbb{R}$ as $$ g(t):=f(x+t(y-x)) $$ Show that for any $t_* \in [0,1]$, $g'(t_*) = \langle \nabla f(x+t_*(y-x)),y-x\rangle$.
The solution for $t_*=0$ is already here Why is any arbitrary directional derivative always recoverable from the gradient?
However, I do not know how to use that trick and generalize it for all points on the line segment?
Use the notion of Fréchet derivative and the chain rule:
$$\partial g(t)=\partial[f(x+t(y-x))]=\partial f(x+t(y-x))\partial[x+t(y-x)]\\=\partial f(x+t(y-x))(y-x)=\langle\nabla f(x+t(y-x)),y-x\rangle$$
where $\partial$ means "Fréchet derivative of".