# Factoring an arbitary variable in mathematica

Imagine we have a equation like this

 gf= 1 + (a3 - a1 x)^2 w1 + (b3 - b2 x)^2 w2


how can I reach the following equation

 gf2= 1 + a1^2 k1^2  xw1 + (b3 - b2 x)^2 xw2


where

k1 = -(a3/a1 - x)


is it possible to use something like this

1 + (a3 - a1 x)^2 w1 + (b3 - b2 x)^2 w2/.-(a3/a1 - x)->k1


actually I tried and didn't work Thanks

• PolynomialQuotient – happy fish Apr 30 '16 at 4:55
• It did not work, could you please explain more? – amin bk Apr 30 '16 at 5:09
• can you provide an expected output? – happy fish Apr 30 '16 at 5:10
• Let me tell you more simple example imagin a1 x1 + a2 y1 + b3 b4 x1 + a2 x1=function then for this function I want to factor a1 x1/a2 the I will get a1 x1/a2( a2 +a2^2 y1/(x1 a1)+... something like this – amin bk Apr 30 '16 at 5:12
• why not use Expand[f/f1]? it gives you the expected output. – happy fish Apr 30 '16 at 5:21

FullSimplify[Eliminate[{gf == 1 + (a3 - a1 x)^2 w1 + (b3 - b2 x)^2 w2,