How can bring these functions under the integral? My question is regarding problem 3.5 in Boyd's and Vandenberghe's "Convex Optimization" book.
However, I want to ask not about the problem itself but rather about the published sample solution by Boyd (here).
In the on of the steps he does the following:
$$
F^{``}(x) = (2/x^3)\int_{0}^{x} f(t)dt - 2f(x)/x^2 + f^`(x)/x \\
= (2/x^3)\int_{0}^{x} (f(t) - f(x) - f^`(x)(t - x))dt
$$
Now, it is more or less clear that we should bring $- 2f(x)/x^2 + f^`(x)/x$ inside the integral. But I don't know how did they do this?
I understand that when you integrate the 2nd part you will get to the first but I am asking about any integration/differentiation rules/tricks that might by have been used in this.
 A: We have
$$ \frac{2}{x^3}\int_0^x f(t) \, dt - \frac{2f(x)}{x^2} + \frac{f'(x)}{x} =  \frac{2}{x^3} \left( \int_0^x f(t) \, dt - x f(x) + \frac{f'(x) x^2}{2} \right). $$
If you want to bring the two last terms in the parenthesis under the integral sign, there are many ways to do so. For example, you can note that $x = \int_0^x 1 \, dt$ and $\frac{x^2}{2} = \int_0^x t \, dt$ and so we get the expression
$$ \frac{2}{x^3} \left( \int_0^x f(t) \, dt - f(x)\int_0^x 1 \, dt + f'(x) \int_0^x t \, dt \right) = \frac{2}{x^3} \left( \int_0^x (f(t) - f(x) + f'(x)t) \, dt \right).$$
Alternatively, $\frac{x^2}{2} = [-\frac{(x-t)^2}{2}]^{t = x}_{t = 0}=\int_0^x (x - t) \, dt$ and then you get the expression
$$ \frac{2}{x^3} \left( \int_0^x f(t) \, dt - f(x)\int_0^x 1 \, dt + f'(x) \int_0^x (x - t) \, dt \right) = \frac{2}{x^3} \left( \int_0^x (f(t) - f(x) - f'(x)(t - x)) \, dt \right). $$
There are also many other options. Which expression you want to get depends on what you want to do with it later.
A: We start with the expression from the previous answer:
$$\frac{2}{x^3}\int_0^x f(t) \, dt - \frac{2f(x)}{x^2} + \frac{f'(x)}{x} =  \frac{2}{x^3} \left( \int_0^x f(t) \, dt - x f(x) + \frac{f'(x) x^2}{2} \right)\tag{1}$$
Let $$g(x)= - x f(x) + \frac{1}{2}f'(x) x^2 \tag{2}$$
What was done in the book, as shown by @levap, in my opinion,is actually to bring $x$ and $x^2/2$ into the integrals so that
$$g(x)= -f(x)\int_0^x 1dt + f'(x) \int_0^x (x - t)dt \tag{3}$$
Since $f(x),f'(x)$ are independent of $t$, they behave like constants and can be freely move into the integral of $t$.
A more elementary way is to differentiate $g(x)$ such that:
$$\int_0^x \left(\frac{d}{dt}g(t)\right)dt=g(x)-g(0)\tag{4}$$
From (2) we obtain
$$\frac{d}{dt}g(t)=-f(t)+\frac{1}{2}t^2 f''(t)\tag{5}$$
From (2) we know that $g(0)=0$. Finally we obtain:
$$\frac{2}{x^3}\int_0^x f(t) \, dt - \frac{2f(x)}{x^2} + \frac{f'(x)}{x} =  \frac{2}{x^3} \left( \int_0^x f(t) \, dt +g(x) \right)$$
$$=\frac{2}{x^3} \left( \int_0^x \left(f(t) -f(t)+\frac{1}{2}t^2 f''(t) \right)dt\right)=\frac{1}{x^3} \left( \int_0^x t^2 f''(t) dt\right)\tag{6}$$
This expression seems to me simpler than the book answer.
