I don't think it's more compact, but just for the sake of it, here's another way:
Collect[Expand[1 + x + x^6 /. x :> xdiff + x0], xdiff] /. xdiff :> x - x0
If you want it organized, apply HoldForm
after evaluating Collect
, but before replacing xdiff
, which can be, for example, achieved with
HoldForm @@ {Collect[Expand[1 + x + x^6 /. x :> xdiff + x0], xdiff]} /. xdiff :> x - x0
This relies on xdiff
being clear, so you may want to package it in a function which keeps your variables fresh, and which gives you the option to hold the form or not as an optional fourth argument (false by default here):
PolynomialShift[poly_, x_Symbol, x0_, hold : (True | False) : False] :=
Module[{xdiff},
If[hold, HoldForm, Identity]
@@ {Collect[Expand[poly /. x :> xdiff + x0], xdiff]} /. xdiff :> x - x0]
(* E.g. *)
In[1]:= PolynomialShift[1 + x + x^6, x, x0]
Out[1]:= 1 + (x - x0)^6 + x0 + 6 (x - x0)^5 x0 + 15 (x - x0)^4 x0^2 +
20 (x - x0)^3 x0^3 + 15 (x - x0)^2 x0^4 + x0^6 + (x - x0) (1 + 6 x0^5)
In[2]:= PolynomialShift[1 + x + x^6, x, x0, True]
Out[2]:= 1 + x0 + x0^6 + (1 + 6 x0^5) (x - x0) + 15 x0^4 (x - x0)^2 +
20 x0^3 (x - x0)^3 + 15 x0^2 (x - x0)^4 + 6 x0 (x - x0)^5 + (x - x0)^6
If you don't care about the ordering, though,
PolynomialShift[poly_, x_Symbol, x0_] :=
Normal[Series[poly, {x, x0, Exponent[poly, x]}]
is probably the most compact you'll get.