I have a question to find the derivative of a definite integral function
$$\frac{d}{dx}\int_{y}^{x} (t-y)g(t) dt$$
The answer is given
$$(x-y)g(x) - \frac{dy}{dx}\int_{y}^{x} g(t) dt$$
As I found that from this answer Derivative of definite integral
The chain rule for such a function is \begin{align} \frac{d}{dx}\int_{y=u(x)}^{x=v(x)} f(t)dt &= \frac{dF}{du}\frac{du}{dx} + \frac{dF}{dv}\frac{dv}{dx} \\&=-f(u(x)) \cdot u'(x) + f(v(x))\cdot v'(x). \end{align}
In this answer, I don't understand why $$\frac{dF}{du}$$ become $$-f(u(x))$$
By using this answer, where my function $$f(t) = (t-y)g(t)$$
As I substituted y into f(t) in my case, the y cancel out. How can I get the right hand part in the given answer.
The situation here is a bit more complicated. You can't use the formula for
$$\frac{\mathrm{d}}{\mathrm{d}x} \int \limits_{u(x)}^{v(x)} f(t) \, \mathrm{d} t$$
because in your case $f(t) = (t-y) g(t)$ also depends on $y(x)$ (which depends on $x$), making the formula invalid.
The right approach is to consider the function
$$G(u, v, y) = \int \limits_u^v (t-y) g(t) \, \mathrm{d} t = \int \limits_u^v t g(t) \, \mathrm{d} t - y \int \limits_u^v g(t) \, \mathrm{d} t.$$
We compute partial derivatives:
$$\begin{align*} \frac{\partial G}{\partial u}(u, v, y) & = -(u-y) g(u) & \text{because } g \text{ is continuous} \\ \frac{\partial G}{\partial v}(u, v, y) & = (v-y) g(v) & \text{because } g \text{ is continuous} \\ \frac{\partial G}{\partial y}(u, v, y) & = -\int \limits_u^v g(t) \, \mathrm{d} t & \text{because } F \text{ is linear w.r.t. } y \end{align*}$$
All the partial derivatives are continuous functions of $(u, v, y)$ hence we can use the chain formula:
$$\begin{align*} \frac{\mathrm{d}}{\mathrm{d}x} G( u(x), v(x), y(x) ) & = \frac{\partial G}{\partial u}(u, v, y) \cdot \frac{\mathrm{d}u}{\mathrm{d}x} + \frac{\partial G}{\partial v}(u, v, y) \cdot \frac{\mathrm{d}v}{\mathrm{d}x} + \frac{\partial G}{\partial y}(u, v, y) \cdot \frac{\mathrm{d}y}{\mathrm{d}x} \\ & = -(u-y) g(u) \cdot u'(x) + (v-y) g(v) \cdot v'(x) - y'(x) \cdot \int \limits_u^v g(t) \, \mathrm{d} t. \end{align*}$$
When we substitute $u = y, v = x$, the first term cancels out, so we finally get
$$\frac{\mathrm{d}}{\mathrm{d}x} \int \limits_y^x (t-y) g(t) \, \mathrm{d} t = (x-y) g(x) - y'(x) \cdot \int \limits_y^x g(t) \, \mathrm{d} t.$$