Deriving an integral with x present in the integral function Revisiting the fundamental theorem of calculus
Imagine you are deriving
$ \frac{\partial}{dx} \int_0^x f(x-a) da$
My gut tells me that the result is $f(x-x)=f(0)$. My gut also tells me thing is wrong, because we should resolve to an expression that is variable with x.
I remember the FTC to say "replace the integral function variable with the derivative variable". In this case, replacing the variable a with x. Where am I getting this wrong?
A further question would be, what is this expression $ \frac{\partial}{dx} \int_0^x f(x^2-a) da$ resolve to? Do we have to perform chain rule over the interior?
 A: In this kind of situation, it's often safest to use a more explicit version of FTC, such as:

*

*Let $f$ be a real-valued function on the closed interval $[a, b]$ and let $F$ be an antiderivative of $f$, i.e. $F'(x) = f(x)$. If $f$ is Riemann-integrable, then $\int_a^b f(x) dx = F(b) - F(a)$.

So let's assume that the conditions hold sufficiently well for what we're trying to do, and let's define $F$ as being a suitable antiderivative of $f$. Then let's start by changing the integral via a substitution $t = x - a$, just to clean up things inside the integral a bit:
$$\begin{eqnarray} \int_0^x f(x - a)\ da & = & \int_x^0 -f(t)\ dt \\
& = & \int_0^x f(t) dt \\
& = & F(x) - F(0) \end{eqnarray}$$
And this is nice, because it's pretty obvious that differentiating this with respect to $x$ gets us $\frac{d}{dx} F(x) = f(x)$.
But that means that we can also see what happens in your second case, this time making the substitution $t = x^2 - a$:
$$\begin{eqnarray} \int_0^x f(x^2 - a)\ da & = & \int_{x^2}^{x^2 - x} -f(t)\ dt \\
& = & -\left(F(x^2 - x) - F(x^2) \right) \\
& = & F(x^2) - F(x^2 - x) \\
\frac{d}{dx} \int_0^x f(x^2 - a)\ da & = & \frac{d}{dx} \left(F(x^2) - F(x^2 - x)\right) \\
& = & F'(x^2) \frac{d}{dx} x^2 - F'(x^2 - x) \frac{d}{dx} (x^2 - x) \\
& = & 2x f(x^2) - (2x - 1) f(x^2 - x) \end{eqnarray}$$
So, as you can see, it's not quite as neat, but it still follows the same general idea. And it's not quite as nice as just applying the chain rule to the interior, which is why it's important to be meticulous about it.
A: I will restrict my analysis to the $x>0$ domain.
There exist a different approach. Your integral can be written under the form:
$$\frac{d}{dx} \int_0^x f(x-a) H(a) da=\frac{d}{dx} (f \star H)(x)\tag{1}$$
where $H$ is the Heaviside step function ($H(a)=1$ for $a>0$ and $H(a)=0$ if $a  \le 0$) and $\star$ the convolution operator.
As the derivative of the convolution of two functions is given by the rule :
$$(f \star g)' = f \star g' = f' \star g$$
(assuming that $f'$ or $g'$ make sens in the context), we can write (1) under the form:
$$f \star H' = f \star \delta = f$$
(where $\delta$ is the Dirac "function").
Therefore, the result is not the number $f(0)$ but the function $f$.
A: You have a problem of the form $\frac{d}{dx}\int_{0}^{x}g(x, a)\,da$. Let $h(x) = \int_{0}^{x}g(x, a)\,da$. We want to compute $h'(x)$. A clean way to solve this is to introduce $I(x_1, x_2) = \int_{0}^{x_1}g(x_2, a)\,da$. Then $h(x) = I(x, x)$. By the chain rule, $h'(x) = I_{x_1}(x, x) + I_{x_2}(x, x)$. By the fundamental theorem of calculus, $I_{x_1}(x_1, x_2) = g(x_2, x_1)$, and by differentiation under the integral sign, $I_{x_2}(x_1, x_2) = \int_{0}^{x_1}g_{x}(x_2, a)\,da$. Thus
$$h'(x) = I_{x_1}(x, x) + I_{x_2}(x, x) = g(x, x) + \int_{0}^{x}g_x(x, a)\,da.$$
In your first example, $g(x, a) = f(x - a)$, so
$$h'(x) = f(x - x) + \int_{0}^{x}f_x(x - a)\,da = f(0) - \int_{0}^{x}\frac{d}{da}(f(x - a))\,da = f(0) - (f(0) - f(x)) = f(x).$$
In the second example, $g(x, a) = f(x^2 - a)$, so
\begin{align}
h'(x) &= f(x^2 - x) + \int_{0}^{x}2xf_x(x^2 - a)\,da \\
&= f(x^2 - x) - 2x\int_{0}^{x}\frac{d}{da}(f(x^2 - a))\,da \\
&= f(x^2 - x) - 2x(f(x^2 - x) - f(x^2)) \\
&= (1 - 2x)f(x^2 - x) + 2xf(x^2).
\end{align}
