$f:[a,b]\to (0,\infty)$ continous, $g:(a,b)\to \Bbb{R}, \ g(t)=\int_a^b(x-t)^2f(x)dx$ prove $g$ attains its minimum on $(a,b)$ The ask also where is the minimum and to charectarize it in terms of $f$.
So I dont know how to show $g$ is differentiable but let's assume for a moment that it is then the minimum is where derrivative is zero so:
$$\frac{d}{dt}g(t)=\frac{d}{dt}\int_a^b(x-t)^2f(x)dx \\
\text{I also don't know if I can do that and if yes then I am not sure why}\\ \int_a^b\frac{d}{dx}(x-t)^2f(x)dx \\ \therefore g'(t)=-\int_a^b2(x-t)f(x)dx$$
and this confuses me even more because in that case the integrand is const end equal zero when $t=x$, but $x$ is a dummy so what does it even mean that $t=0$ ?
 A: Hint: Expanding $(x-t)^2$ gives
$$g(t) = \int_a^bx^2f(x)\,dx -2t\int_a^bxf(x) \,dx+t^2\int_a^b f(x)\,dx.$$
Thus $g$ is parabola facing upwards. You want to show $g'(t)=0$ for some $t\in (a,b).$
A: First all, we observe that
$g(t) = \displaystyle \int_a^b (x - t)^2 f(x) \; dx = \int_a^b (x^2 - 2xt + t^2) f(x) \; dx$
$= \displaystyle \int_a^b (t^2 f(x) - 2t xf(x) + x^2 f(x)) \; dx$
$= t^2 \displaystyle \int_a^b f(x) \; dx - 2t \int_a^b x f(x) \; dx + \int_a^b x^2 f(x) \; dx, \tag 1$
since $t$ is constant with respect to $x$, the variable of integration.  With
$g(t) = t^2 \displaystyle \int_a^b f(x) \; dx - 2t \int_a^b x f(x) \; dx + \int_a^b x^2 f(x) \; dx, \tag 2$
we see that $g(t)$ is just a quadratic polynomial in $t$ whose coefficients are given by the integrals occurring in (2); we further observe that since
$f[a, b] \to (0, \infty) \tag 3$
is continuous, it takes its minimum $m_f > 0$ on the compact interval $[a, b]$, whence
$f(x) \ge m_f > 0, \; x \in [a, b], \tag 4$
so that
$\displaystyle \int_a^b f(x) \; dx \ge \int_a^b m_f \; dx = m_f(b - a) > 0, \tag 5$
which in turn shows us that (2) is in fact a bona fide quadratric, that is, it's leading coefficient (of $t^2$) is non-zero.  We see that in fact $g(t)$ is defined on all of $\Bbb R$:
$g: \Bbb R \to \Bbb R, \tag 6$
and that
$g'(t) = 2t \displaystyle \int_a^b f(x) \; dx - 2 \int_a^b xf(x) \; dx, \tag 7$
$g''(t) = 2 \displaystyle \int_a^b f(x) \; dx > 0; \tag 8$
if follows from (7) and (8) that $g(t)$ takes on its global minimum value at that $t_m$ such that
$g'(t_m) = 2t_m \displaystyle \int_a^b f(x) \; dx - 2 \int_a^b xf(x) \; dx = 0, \tag 9$
that is, at
$t_m = \dfrac{\displaystyle \int_a^b xf(x) \; dx}{\displaystyle \int_a^b f(x) \; dx}; \tag{10}$
it remains then to show that
$t_m \in (a, b), \text{that is} \; a < t_m < b; \tag{11}$
to this end we define the function
$h:[a, b] \to (0, \Bbb R); \; h(x) = \dfrac{f(x)}{\displaystyle \int_a^b f(x) \; dx}; \tag{12}$
we see from (4) and (5) that 
$h(x) > 0; \tag{13}$
also,
$\displaystyle \int_a^b h(x) \; dx = \dfrac{\displaystyle \int_a^b f(x) \; dx}{\displaystyle \int_a^b f(x) \; dx} = 1; \tag{14}$
now since
$a < x < b, \; x \in (a, b), \tag{15}$
it follows that
$a = \displaystyle a \int_a^b h(x) \; dx = \int_a^b ah(x) \; dx$
$< \displaystyle \int_a^b xh(x) \; dx < \int_a^b bh(x) \; dx = b \int_a^b h(x) dx = b; \tag{16}$
using (10) and (12) we see that 
$t_m = \displaystyle \int_a^b xh(x) \; dx, \tag{17}$
whence (16) yields
$a < t_m < b, \tag{18}$
as required.
Remarks:  By expanding $(x - t)^2$ and bringing $t$ outside of the integral, we avoid questions of differentiating under the integral sign, which though easy merely adds an unnecessary layer of complication.  One may of course if so desired differentiate under the integral, obtaining
$g'(t) = -\displaystyle \int_a^b 2(x - t)f(x) \; dx, \tag{19}$
which of course ultimately leads to the same result for $t_m$ as has been obtained here.  Bringing out the powers of $t$ also provides an easy route to the result that $g(t)$ is differentiable. End of Remarks.
A: Taking on the momentum you have had...$g'(t) = 0 \implies t = \dfrac{\displaystyle \int_{a}^b xf(x)dx}{\displaystyle \int_{a}^b f(x)dx} \in (a,b)$. This shows $g$ attended a minimum in $(a,b)$.
