Let $u(t)=t^2$. Find the best approximation $v(t)$ of the form $v(t) = ct+d$ ($c,d\in\mathbb{R}$) to $u(t)$ in $L^2[0,1]$.
We can define the set $V:=\{ct+d:c,d\in\mathbb{R}, t\in[0,1]\}$.
$$\inf\limits_{v(t)\in V} \left(\int_0^1 (t^2-ct-d)^2dt \right)^{1/2}=\inf\limits_{v\in V} \left(\frac{c^2}3+c(d-\frac12)+d^2-\frac{2d}3+\frac15 \right)^{1/2}$$
Now,
$$\frac{\partial h}{\partial c}=\frac{2c}{3}+d-\frac12 = 0$$ $$\frac{\partial h}{\partial d}=c+2d-\frac23=0$$
Solving these equations simultaneously, we get $c=1, d=-\frac16$.
To check that $c,d$ are the minimum values, we see that the determinant of the Hessian matrix is
$$|H|=\begin{Vmatrix} \frac23 & 1\\ 1 & 2 \end{Vmatrix}=\frac13>0$$
Thus we have that the function $v(t) = t-\frac16$ is the best approximation.
Please let me know if my approach is correct.
Yes, your answer looks correct. The closest point $p$ to a closed subspace $M$ of a Hilbert space $H$ is the unique $m \in M$ such that $(p-m)\perp M$. You can see this because it gives the following for all $m'\in M$ \begin{align} \|p-m'\|^2&=\|(p-m)+(m-m')\|^2 \\ &=\|p-m\|^2+\|m-m'\|^2 \\ & \ge \|p-m\|^2 \end{align} with equality iff $m=m'$. Closest point and orthogonal projection are the same in this context. So, you want to find the unique $c$ and $d$ such that $$ \langle t^2 - ct-d,t\rangle = 0 \\ \langle t^2 - ct-d,1\rangle = 0. $$ This gives equations $$ \frac{1}{4}-c\frac{1}{3}-d\frac{1}{2} = 0\\ \frac{1}{3}-c\frac{1}{2}-d=0. $$ Multiply the top by $2$ and subtract the bottom equation to eliminate $d$: $$ \left(\frac{1}{2}-\frac{1}{3}\right)-\left(\frac{2}{3}-\frac{1}{2}\right)c=0, \\ \frac{1}{6}=\frac{1}{6}c \implies c=1 \implies d=\frac{1}{6}. $$