|
3.3.1 Structural Operations on Polynomials

Structural operations on polynomials.
Here is a polynomial in one variable.
In[1]:= (2 + 4 x^2)^2 (x - 1)^3
Out[1]= 
Expand expands out products and powers, writing the polynomial as a simple sum of terms.
In[2]:= t = Expand[ % ]
Out[2]= 
Factor performs complete factoring of the polynomial.
In[3]:= Factor[ t ]
Out[3]= 
FactorTerms pulls out the overall numerical factor from t.
In[4]:= FactorTerms[ t ]
Out[4]= 
There are several ways to write any polynomial. The functions Expand, FactorTerms and Factor give three common ways. Expand writes a polynomial as a simple sum of terms, with all products expanded out. FactorTerms pulls out common factors from each term. Factor does complete factoring, writing the polynomial as a product of terms, each of as low degree as possible.
When you have a polynomial in more than one variable, you can put the polynomial in different forms by essentially choosing different variables to be "dominant". Collect[poly, x] takes a polynomial in several variables and rewrites it as a sum of terms containing different powers of the "dominant variable" x.
Here is a polynomial in two variables.
In[5]:= Expand[ (1 + 2x + y)^3 ]
Out[5]= 
Collect reorganizes the polynomial so that x is the "dominant variable".
In[6]:= Collect[ %, x ]
Out[6]= 
If you specify a list of variables, Collect will effectively write the expression as a polynomial in these variables.
In[7]:= Collect[ Expand[ (1 + x + 2y + 3z)^3 ], {x, y} ]
Out[7]= 

Controlling polynomial expansion.
This avoids expanding parts which do not contain x.
In[8]:= Expand[(x + 1)^2 (y + 1)^2, x]
Out[8]= 
This avoids expanding parts which do not contain objects matching b[_].
In[9]:= Expand[(a[1] + a[2] + 1)^2 (1 + b[1])^2, b[_]]
Out[9]= 

Expanding powers.
Mathematica does not automatically expand out expressions of the form (a b)^c except when c is an integer. In general it is only correct to do this expansion if a and b are positive reals. Nevertheless, the function PowerExpand does the expansion, effectively assuming that a and b are indeed positive reals.
Mathematica does not automatically expand out this expression.
In[10]:= (x y)^n
Out[10]= 
PowerExpand does the expansion, effectively assuming that x and y are positive reals.
In[11]:= PowerExpand[%]
Out[11]= 
Log is not automatically expanded out.
In[12]:= Log[%]
Out[12]= 
PowerExpand does the expansion.
In[13]:= PowerExpand[%]
Out[13]= 

Ways of collecting terms.
Here is an expression involving various functions f.
In[14]:= t = 3 + x f[1] + x^2 f[1] + y f[2]^2 + z f[2]^2
Out[14]= 
This collects terms that match f[_].
In[15]:= Collect[t, f[_]]
Out[15]= 
This applies Factor to each coefficient obtained.
In[16]:= Collect[t, f[_], Factor]
Out[16]= 
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT. SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION. |