Skip to main content

sorting - How can I sort the polynomial by the degree of $x$


f1 = a x^2 + b x + c + x^3


(* a x^2+b x+c+x^3 *)



f1 /. x -> (x - a/3) // Expand


(* (2 a^3)/27-(a^2 x)/3-(a b)/3+b x+c+x^3 *)




I've tried this:


f1 /. x -> (x - a/3) // Expand // Collect[#, x] &


(* (2 a^3)/27+x (b-a^2/3)-(a b)/3+c+x^3 *)



f1 /. x -> (x - a/3) // Expand // Collect[#, x] & // PolynomialForm



(* (2 a^3)/27-(b a)/3+x^3+c+(b-a^2/3) x *)





Comments