4
$\begingroup$
Example: g[x_] = (x^3 - 27)/((x - 3)*(x + 1))

Here the common factor is x-3, how can i extract that common factor from a function (g(x)) and put it as a separate ..

Example: f[x] = x-3 
$\endgroup$
  • 2
    $\begingroup$ f[x_] = Numerator[g[x]]/Numerator[g[x] // Cancel] // Cancel $\endgroup$ – Bob Hanlon Jan 28 '17 at 14:46
11
$\begingroup$

I think PolynomialGCD is the most direct tool:

g[x_] = (x^3 - 27)/((x - 3)*(x + 1));

PolynomialGCD @@ Through @ {Numerator,Denominator} @ g[x]

-3+x

If you don't like operator notation, you might find this version preferable:

With[{n = Numerator[g[x]], d = Denominator[g[x]]}, PolynomialGCD[n,d]]

-3+x

|improve this answer|||||
$\endgroup$
  • $\begingroup$ May I ask why you enclosed your second example in a With statement? E.g., what about just: PolynomialGCD[Numerator[g[x_]], Denominator[g[x_]]]? $\endgroup$ – theorist Mar 24 '18 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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