Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Maybe a better way to write the code that should answer the computational question behind the question is as follows. The posted code uses abs(E) at many places. Well, let us use an other variable for this expression. Since retyping and/or replacing is complicated, i will use E instead below. Since n runs in 0, 1, 2, 3, 4, 5, 6, ... it is a good idea to define a function $f$ of n (depending on the many parameters). So let us start with:

var('A, B, C, D, E, α, β, γ')

f = lambda n : (
   (8*A + 6*B + 4*C + 4*D + 2*E + 4*α + 2*β + γ)^n
 - (7*A + 6*B + 4*C + 4*D + 2*E + 4*α + 2*β + γ)^n
 - (7*A + 5*B + 4*C + 4*D + 2*E + 4*α + 2*β + γ)^n
 + (6*A + 5*B + 4*C + 4*D + 2*E + 4*α + 2*β + γ)^n
 - (6*A + 5*B + 3*C + 4*D + 2*E + 4*α + 2*β + γ)^n
 + (5*A + 5*B + 3*C + 4*D + 2*E + 4*α + 2*β + γ)^n
 + (5*A + 4*B + 3*C + 4*D + 2*E + 4*α + 2*β + γ)^n
 - (5*A + 4*B + 3*C + 3*D + 2*E + 4*α + 2*β + γ)^n
 - (5*A + 4*B + 3*C + 3*D +   E + 4*α + 2*β + γ)^n
 + (5*A + 4*B + 3*C + 2*D +   E + 4*α + 2*β + γ)^n
 + (5*A + 3*B + 3*C + 2*D +   E + 4*α + 2*β + γ)^n
 - (4*A + 3*B + 3*C + 2*D +   E + 4*α + 2*β + γ)^n
 + (4*A + 3*B + 2*C + 2*D +   E + 4*α + 2*β + γ)^n
 - (4*A + 3*B + 2*C + 2*D +   E + 3*α + 2*β + γ)^n
 - (4*A + 3*B + 2*C + 2*D +   E + 3*α +   β + γ)^n
 + (4*A + 3*B + 2*C + 2*D +   E + 2*α +   β + γ)^n
 - (4*A + 3*B + 2*C + 2*D +   E + 2*α +   β)^n
 + (4*A + 3*B + 2*C + 2*D +   E +   α +   β)^n
 + (4*A + 3*B + 2*C + 2*D +   E +   α)^n
 - (4*A + 3*B + 2*C + 2*D +   E)^n
 + (4*A + 3*B +   C + 2*D +   E)^n
 - (3*A + 3*B +   C + 2*D +   E)^n
 - (3*A + 2*B +   C + 2*D +   E)^n
 + (3*A + 2*B +   C +   D +   E)^n
 + (3*A + 2*B +   C +   D)^n
 - (3*A + 2*B +   C)^n
 - (3*A +   B +   C)^n
 + (2*A +   B +   C)^n
 - (2*A +   B)^n
 + (  A +   B)^n
 +    A^n
)/factorial(n)

Then for instance f(4) is an expression in the many variables $A, B, C, \bbox[yellow]{\qquad D\qquad }, E, α, β, γ$, and what we want now is to replace $D$ by either $A+E$, or by $A$. OK, let's see what happens when we substitute, then factorize, since you have a factor:

sage: f(4).subs(D==A+E).simplify_full().factor()
1/2*(2*A^3 + 3*A^2*B + A*B^2 + 8*A*E^2 + 4*B*E^2 + 4*C*E^2 + 6*E^3 - 4*A^2*α - 4*A*B*α
                + 8*E^2*α + 2*α^3 - 2*A^2*β - 2*A*B*β + 4*E^2*β + 3*α^2*β + α*β^2
                - A^2*γ - A*B*γ + 2*E^2*γ + α^2*γ + α*β*γ)
    *(12*A + 6*B + 4*C + 6*E + 4*α + 2*β + γ)

sage: f(4).subs(D==A).simplify_full().factor()
1/2*(2*A^3 + 3*A^2*B + A*B^2 - 4*A^2*α - 4*A*B*α
             + 2*α^3 - 2*A^2*β - 2*A*B*β + 3*α^2*β + α*β^2
             - A^2*γ - A*B*γ + α^2*γ + α*β*γ)
   *(12*A + 6*B + 4*C + 2*E + 4*α + 2*β + γ)

(Results were manually adjusted, lines broken to fit in the asksage page.)

Now there is no computer algebra functionality to split a polynomial in two, so that the two pieces have "good factorizations each". However, we have some information from the manual computation. One piece does not involve $A$. So let us take that factor, and split it w.r.t. $A$ into an $A$-free part, and a part where we can factorize $A$:

In the command line:

sage: expression = [e for e, mul in f(4).subs(D==A).simplify_full().factor().factor_list()][0]
sage: expression
2*A^3 + 3*A^2*B + A*B^2 - 4*A^2*α - 4*A*B*α + 2*α^3 - 2*A^2*β - 2*A*B*β + 3*α^2*β + α*β^2 - A^2*γ - A*B*γ + α^2*γ + α*β*γ
sage: expression.subs(A==0).factor()
(2*α + β + γ)*(α + β)*α
sage: (expression - _).factor()
(2*A + B - 4*α - 2*β - γ)*(A + B)*A

However, when we substitute D==A+E instead, there is no good parallel found this way.

The question comes without the mathematical structure, so that missing more insight i tried to factorize also some further expression. It turns out for instance that when asking for

f(6).subs(D==A).factor()

there is indeed a non-trivial factor,

(12*A + 6*B + 4*C + 2*E + 4*α + 2*β + γ)

which is not really expected when building a sum of many six power linear expressions. And

f(6).subs(D==A+E).factor()

shows the factor

(12*A + 6*B + 4*C + 6*E + 4*α + 2*β + γ)

This motivated me to break the linearity in each base taken to the sixth power, so let us introduce a $t$ and cover both cases by substituting $D=A+tE$:

sage: var('t');
sage: f(6).subs(D==A+t*E).factor()

And there is a "small factor"

(4*E*t + 12*A + 6*B + 4*C + 2*E + 4*α + 2*β + γ)

(And further mess around.) I am stopping here the answer. (But with more insight, one must be able to do / to guess more...)