Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is there a way to optimize this equation-solving code to run in a reasonable timeframe?

I have the following lines in Sage:

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

f = lambda n : (
   (12*A + 6*B + 4*C + 2*E + 4*α + 2*β + γ)^n
 - (11*A + 6*B + 4*C + 2*E + 4*α + 2*β + γ)^n
 - (11*A + 5*B + 4*C + 2*E + 4*α + 2*β + γ)^n
 + (10*A + 5*B + 4*C + 2*E + 4*α + 2*β + γ)^n
 - (10*A + 5*B + 3*C + 2*E + 4*α + 2*β + γ)^n
 + ( 9*A + 5*B + 3*C + 2*E + 4*α + 2*β + γ)^n
 + ( 9*A + 4*B + 3*C + 2*E + 4*α + 2*β + γ)^n
 - ( 8*A + 4*B + 3*C + 2*E + 4*α + 2*β + γ)^n
 - ( 8*A + 4*B + 3*C +   E + 4*α + 2*β + γ)^n
 + ( 7*A + 4*B + 3*C +   E + 4*α + 2*β + γ)^n
 + ( 7*A + 3*B + 3*C +   E + 4*α + 2*β + γ)^n
 - ( 6*A + 3*B + 3*C +   E + 4*α + 2*β + γ)^n
 + ( 6*A + 3*B + 2*C +   E + 4*α + 2*β + γ)^n
 - ( 6*A + 3*B + 2*C +   E + 3*α + 2*β + γ)^n
 - ( 6*A + 3*B + 2*C +   E + 3*α +   β + γ)^n
 + ( 6*A + 3*B + 2*C +   E + 2*α +   β + γ)^n
 - ( 6*A + 3*B + 2*C +   E + 2*α +   β)^n
 + ( 6*A + 3*B + 2*C +   E +   α +   β)^n
 + ( 6*A + 3*B + 2*C +   E +   α)^n
 - ( 6*A + 3*B + 2*C +   E)^n
 + ( 6*A + 3*B +   C +   E)^n
 - ( 5*A + 3*B +   C +   E)^n
 - ( 5*A + 2*B +   C +   E)^n
 + ( 4*A + 2*B +   C +   E)^n
 + ( 4*A + 2*B +   C)^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)

solve([f(3) == 0, f(4) == 0, f(5) == d], α, β, γ)

I want Sage to solve this system of equations for the three Greek-letter variables in terms of the five English-letter variables. However, when I ask Sage to solve this, it just sits and spins at maximum CPU usage and steadily-increasing RAM usage until I kill the process. I've waited over fifteen minutes without it completing.

Are there any ways to make this more performant?