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$
1
  • 2
    $\begingroup$ f[x_] = Numerator[g[x]]/Numerator[g[x] // Cancel] // Cancel $\endgroup$
    – Bob Hanlon
    Jan 28, 2017 at 14:46

1 Answer 1

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

$\endgroup$
1
  • $\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, 2018 at 1:16

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.