Calculate for which values $a$ and $b$ the integral
$$\int_{0}^{1} \left( ax+b+\frac{1}{1+x^{2}} \right)^{2}\,dx$$
takes its minimum possible value?
For being honest I'm not sure how to try this, but my idea is to calculate its derivative using fundamental calculus theorem as $\left(ax+b+\frac{1}{1+x^{2}} \right)^{2}$ is a continuous function over $[0,1]$. And then, evaluate the integral over $0,1$ and the values where the derivative we calculate is zero and find which $a$ and $b$ does the work. Sorry but this is the first problem of this type I'm trying. Thanks
Let \begin{align}f(a,b)=\int_{0}^{1} \left( ax+b+\frac{1}{1+x^{2}} \right)^{2}dx\implies \frac{\partial f(a,b)}{\partial a}&=\int_0^12x\left( ax+b+\frac{1}{1+x^{2}} \right)\,dx\\&=\left[\frac{2ax^3}3+bx^2+\ln(1+x^2)\right]_0^1\end{align} so $$\frac{\partial f(a,b)}{\partial a}=\frac23a+b+\ln2=0\tag1$$ for critical points. Similarly \begin{align}f(a,b)=\int_{0}^{1} \left( ax+b+\frac{1}{1+x^{2}} \right)^{2}dx\implies \frac{\partial f(a,b)}{\partial b}&=\int_0^12\left( ax+b+\frac{1}{1+x^{2}} \right)\,dx\\&=\left[ax^2+2bx+2\tan^{-1}x\right]_0^1\end{align} so $$\frac{\partial f(a,b)}{\partial b}=a+2b+\frac\pi2=0\implies\frac12a+b+\frac\pi4=0\tag2$$ for critical points. Performing $(1)-(2)$ gives $$\frac16a=\frac\pi4-\ln2\implies a=\boxed{\frac{3\pi}2-6\ln2}$$ and putting this into $(2)$ gives $$b=-\frac12a-\frac\pi4=\boxed{-\pi+3\ln2}.$$