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
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
PolynomialGCD[Numerator[g[x_]], Denominator[g[x_]]]
?
$\endgroup$
f[x_] = Numerator[g[x]]/Numerator[g[x] // Cancel] // Cancel
$\endgroup$