Find $a$ and $b$ for which $\int_{0}^{1}( ax+b+\frac{1}{1+x^{2}} )^{2}\,dx$ takes its minimum possible value.

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}.$$


We can also solve this problem by projecting $f(x) = -\dfrac{1}{1+x^2}$ on the linear space spanned by all linear functions defined on $[0,1]$ where we use the inner product $\langle f,g\rangle=\int_0^1f(x) g(x) dx$.

The normalized constant function $e_0(x) = 1$ can be taken to be one basis vector of the linear space of linear function. The function $h(x) = x$ is linearly independent from $e_0(x)$ but it is not orthogonal to it. Using the Gram–Schmidt process we can find the correct basis vector as follows. We subtract from $h(x)$ its component in the direction of $e_0(x)$ and then we normalize the result. We put:

$$g(x) = h(x) - \langle h,e_0\rangle e_0(x) = x - \int_0^1 x dx = x - \frac{1}{2}$$

Normalizing $g(x)$ then gives us the other basis vector $e_1(x)$ of the space of the linear functions:

$$e_1(x) = \frac{g(x)}{\sqrt{\langle g,g\rangle}} = \frac{x-\frac{1}{2}}{\sqrt{\int_0^1 \left(x-\frac{1}{2}\right)^2 dx }} = 2\sqrt{3}\left(x-\frac{1}{2}\right)$$

The projection of $f(x)$ on the linear space spanned by the linear functions is then:

$$\langle f,e_0 \rangle e_0(x) + \langle f,e_1 \rangle e_1(x) = 3\log(2) -\pi +\left( \frac{3\pi}{2}-6\log(2)\right)x $$