As an example of what I'm trying to achieve, I create a known function, say $(x + 4)^2 (x + 5)$, which expands out to $80 + 56 x + 13 x^2 + x^3$. I'd like to go backwards in this procedure, where I have a known polynomial and want to express it as a product of various functions to powers. My first thought was using Solve to solve everything to individual powers, unsuccessfully, since there is no system to solve for multiple parameters. Naturally, the solution might not be unique, but that's not particularly relevant for my process.

I am looking for a function that would look something like:

FindPowers[80 + 56 x + 13 x^2 + x^3 == (x+4)^a (x+5)^b (x+3)^c, {a,b,c}]

and return the following result:

{a->2, b->1, c->0}

This is obviously a simple example, but does MMA have any function that would almost "trial and error" combinations until it found a suitable solution? I do not need any particular solution, but just to know that a given polynomial may be expressed via specific predefined products.

Please feel free to suggest amendments to the title, I am unsure what to call this method.

EDIT: More complex example.

In particular, my problem is not with standard polynomials in terms of $x$; as pointed out there are plenty of standard functions which can make this trivial. My particular problems are dealing with symbolic polynomial functions, such as x[1] - x[2] - x[3] y[2] + x[4] y[2] - x[1] y[3] + x[2] y[3] - x[1] z[3] + x[2] z[3] + x[1] y[2] z[3] - x[4] y[2] z[3] - x[1] y[2] z[4] + x[3] y[2] z[4] + x[1] y[3] z[4] - x[2] y[3] z[4].

Given a long set of identities (some involving all the terms, some only involving one), I am trying to see if there is a way to represent this arbitrary polynomial as a product of some kind of all of these identities (of which there are a lot). It may well be that there is no way to represent this as a product, which is equally useful to know. As an example, my identities may look something like s345 = (x[3] - x[4] y[3] - x[1] z[3] + x[1] y[3] z[4])/(x[1] (x[3] - x[4])), and others which may be simpler, or of a different form entirely. My problem posed is quite general, however, I chose my simple example to illustrate the general idea of what I am trying to achieve.

  • $\begingroup$ Ahm... FullSimplify[80 + 56 x + 13 x^2 + x^3]? $\endgroup$
    – corey979
    Feb 19, 2019 at 20:13
  • $\begingroup$ Works for this minimal example but wouldn’t work for my general problem. Instead of these trivial polynomials, I have more complicated definitions I’m afraid. $\endgroup$
    – Brad
    Feb 19, 2019 at 20:17
  • 2
    $\begingroup$ @Brad you might want to add a more complex example is the current one doesn't capture the difficulties if the real use case. Because for polynomials, you'll probably mostly get answers along the lines of "find the roots and factor it" $\endgroup$
    – Lukas Lang
    Feb 19, 2019 at 20:56
  • $\begingroup$ FactorList will indicate what are the explicit factors and their powers. $\endgroup$ Feb 19, 2019 at 23:42
  • $\begingroup$ Thank you for your help so far. I will attempt to use the below answers, and then post a suitable example if needed. $\endgroup$
    – Brad
    Feb 20, 2019 at 12:15

2 Answers 2


Try this code:

equ = CoefficientList[ Normal[80 + 56 x + 13 x^2 + x^3 - 
      Series[(x + 4)^a (x + 5)^b (x + 3)^c, {x, 0, 3}]], x];
FindInstance[ 0 == equ && 0 <= a && 0 <= b && 0 <= c && 3 == a + b + c,
     {a, b, c}, Integers, 1]

which returns your result. It doesn't involve factoring polynomials. The code can be easily modified for similar kind of problems more complicated then just factoring a single polynomial.

The code I gave is comparatively simple and general. It involves power series in one variable x and getting the list of coefficients of a polynomial in one variable, and a very general function FindInstance[] which find solutions of equations and inequalities.

Your revised question involves several variables and it seems that my solution is not adequate for that. You may require Grobner basis techniques. I am not sure of that, but a simple example with two variables may make the situation clearer.

  • $\begingroup$ Thank you for your answer. I will explore FindInstance and the related terms in your code. Are you able to give a brief explanation of the stages of work in the code, in terms of what each function achieves? $\endgroup$
    – Brad
    Feb 20, 2019 at 12:19
  • $\begingroup$ I like how this works. I will try and generalise to multiple variables and see if this solves my problem. This has the essence of what I was trying to do; if you have a look at my edited example, do you think this method is possible to extend to that? $\endgroup$
    – Brad
    Feb 20, 2019 at 12:33

You can check if a member of the candidate list of factors appear in FactorList of the input polynomial; if it does, you can get its exponent from the second entry of the corresponding element in FactorList:

rhs = {3 + x, 4 + x, 5 + x};
Rest[FactorList[80 + 56 x + 13 x^2 + x^3]]

{{4 + x, 2}, {5 + x, 1}}

factors = Association[Thread[Rule @@ #] & /@ Rest[FactorList[80 + 56 x + 13 x^2 + x^3]]]

# -> factors@# & /@ rhs /. _Missing -> 0

{3 + x -> 0, 4 + x -> 2, 5 + x -> 1}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.