Thanks for the reply. I tried the function using CoefficientList
and Total
on this example 2 with the last coefficient larger than 1:
f[x_] = 6x + 11;
Total[CoefficientList[f[x], x] x^Exponent[f[x], x]]
However, the output produced is 17x
instead of 7x
due to the calculation of the last coefficient (it should convert the last coefficient [11] -> x). Is there a way to achieve this?
Edit: Found a way which kinda works:
Total[CoefficientList[f[x], x]] - (Coefficient[f[x], x, 0] - 1)
but will like to know if there's a more efficient way than this.