0
$\begingroup$

I have a polynomial in falling factorial form, i. e. $-x+7(-1+x)x+6(-2+x)(-1+x)x+(-3+x)(-2+x)(-1+x)x$.

Now i want to extract the "outermost" coefficients $\{-1,7,6,1\}$. I have this code to get all the digits next to a left bracket:

numbersNextToLeftBracket = Cases[fallingFactorialForm, a_?(NumberQ) (b_) :> a, {1}]

However, this only gives me $\{-1,7,6\}$ because the last $1$ is not visible. How can I rewrite this so it includes all these coefficients?

$\endgroup$
4
  • 1
    $\begingroup$ This may be better suited to the Mathematica SE. $\endgroup$ Commented Jun 28 at 14:11
  • 1
    $\begingroup$ Based on the FullForm[fallingFactorialForm], for the Cases pattern, try t :(Times[coef_Integer, __] | Times[coef_Plus, __]) :> If[IntegerQ[coef], coef, 1] $\endgroup$
    – user170231
    Commented Jun 28 at 18:39
  • $\begingroup$ Perfect, thank you! $\endgroup$
    – mhighwood
    Commented Jun 28 at 18:42
  • $\begingroup$ I'm sure there's an edge case that that code does not address. If you want to be careful, you should check in with the gurus at the Mma SE. $\endgroup$
    – user170231
    Commented Jun 28 at 18:48

0

You must log in to answer this question.

Browse other questions tagged .