If I have a polynomial, say $p(x) = 6x^3 - x^2 + x$, and I want to express that in terms of a sum of other polynomials, how may I do that in Mathematica? Specifically I would like to say that $$p(x) = \sum_{i = 0}^3 \alpha_i P_i(x)$$ where $P_i(x)$ is the $i^{th}$ Legendre Polynomial (not super important what exactly the other polynomial is).
I have attempted the following:
p = 6*x^3 - x^2 + x;
Solve[p == (C3*LegendreP[3, x] + C2*LegendreP[2, x] +
C1*LegendreP[1, x] + C0*LegendreP[0, x]), {C3, C2, C1, C0}]
but it gives
{{C0 -> x - C1 x - x^2 + 6 x^3 - 1/2 C2 (-1 + 3 x^2) -
1/2 C3 (-3 x + 5 x^3)}}
as the output when I know (for this example) the C's are real numbers.