Legendre polynomials form an orthogonal basis, meaning any polynomial can be expressed as a linear combination of these polynomials. The general formula for expressing a polynomial $f(x)$ of degree $n$ in terms of Legendre polynomials up to $P_n(x)$ is $f(x) = \sum_{k=0}^n c_k P_k(x)$, where the coefficients $c_k$ can be found using the orthogonality relation or by comparing coefficients as done above.