Let $g_1(t), \ldots, g_n(t)$ be prescribed, linearly independent functions. Explain how to best approximate a function $f(t)$ by a linear combination $c_1 g_1(t)+\cdots+c_n g_n(t)$ when the least squares error is measured in a weighted $\mathrm{L}^2$ norm $\|f\|_w^2=\int_a^b f(t)^2 w(t) d t$ with weight function $w(t)>0$.