# Why does FromDigits factor a polynomial output?

The code

testseq = {0, 0, 4, -3, 2, 5, 11};
testfunction1[x_] := FromDigits[Reverse[testseq], x];
Print[testfunction1[x]];
testfunction2[x_] := Dot[testseq, Power[x, Range[Length[testseq]] - 1]];
Print[testfunction2[x]];


gives me

(4 - 3x)x^2 + x^4(2 + 5x + 11x^2)

4x^2 - 3x^3 + 2x^4 + 5x^5 + 11x^6

The first result is surprising, the second as expected. Why do I get the first result?

• FromDigits[] is in fact a documented way for producing polynomials that are in Horner form. – J. M.'s ennui Aug 1 '17 at 7:47
• Thank you, J.M. that seems a potentially very useful feature. May I ask where is it documented ? Also wouldn't Horner's form according to mathworld be (((((11x+5)x+2)x-3)x+4)x^3 ? – Simon Aug 1 '17 at 8:05
• Programming hint: Save yourself some typing. f[x] gives the same result as Print[f[x]];. See this answer for further useful info. – m_goldberg Aug 1 '17 at 12:58
• Thank you m_goldberg, that is a useful hint and an interesting read. I have got into the habit of using ; as a delimiter because it seems to be necessary within a Module. – Simon Aug 1 '17 at 15:21

## 1 Answer

You need Apart or Expand

list = {0, 0, 4, -3, 2, 5, 11};

FromDigits[Reverse[list], x] // Apart


4 x^2 - 3 x^3 + 2 x^4 + 5 x^5 + 11 x^6

Why?

Probably because FromDigits Simplify's automatically (the factored form is considererd to be the simpler one)

• Thank you eldo. However, when I apply Simplify to 4 x^2 - 3 x^3 + 2 x^4 + 5 x^5 + 11 x^6 it just takes out the factor of x^2. – Simon Aug 1 '17 at 10:54
• Yes, the behaviour of Simplify is complex, but you can control it to a certain degree (see Doc and many QAs here) – eldo Aug 1 '17 at 11:07