X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=doc%2Ftutorial%2Fginac.texi;h=54414c91555175b9b451c6b477e146f9e766e249;hp=98033e40767d1914fc7f8fded5e5a99f4a4127a5;hb=778927a23b7807cb9809047211265000650eda56;hpb=1a75b1adc0e425989d9d3bf1b208411b738b9672 diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index 98033e40..54414c91 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -3405,6 +3405,7 @@ argument. You can not use functions like @samp{diff()}, @samp{op()}, @subsection Expanding and collecting @cindex @code{expand()} @cindex @code{collect()} +@cindex @code{collect_common_factors()} A polynomial in one or more variables has many equivalent representations. Some useful ones serve a specific purpose. Consider @@ -3463,6 +3464,25 @@ d*sin(x)+(d*sin(x)+sin(y)+d*sin(y)+sin(x))*p+(d*sin(x)+sin(y)+d*sin(y)+sin(x))*q (1+q+d*(1+q+p)+p)*sin(y)+(1+q+d*(1+q+p)+p)*sin(x) @end example +Polynomials can often be brought into a more compact form by collecting +common factors from the terms of sums. This is accomplished by the function + +@example +ex collect_common_factors(const ex & e); +@end example + +This function doesn't perform a full factorization but only looks for +factors which are already explicitly present: + +@example +> collect_common_factors(a*x+a*y); +(x+y)*a +> collect_common_factors(a*x^2+2*a*x*y+a*y^2); +a*(2*x*y+y^2+x^2) +> collect_common_factors(a*(b*(a+c)*x+b*((a+c)*x+(a+c)*y)*y)); +(c+a)*a*(x*y+y^2+x)*b +@end example + @subsection Degree and coefficients @cindex @code{degree()} @cindex @code{ldegree()}