[Maxima] Factoring out expressions
macrakis at alum.mit.edu
Sun Feb 10 14:21:45 CST 2008
On Feb 10, 2008 2:49 PM, Daniel Cabrini Hauagge <daniel.hauagge at gmail.com>
> 2 2
> eq : t (b + a) + t (y + x)
> and I want to factor out "t". When I use the function factor or
> factorsum t is correctly isolated
> but (b+a)^2 and (y+x)^2 are expanded
...When I use factorout I get the result that I'm looking for
> 2 2
> (%o5) t ((y + x) + (b + a) )
> but I have to pass y, x, b, and a as arguments to factorout...
> which is not very practical when you have huge expressions full of
> variables. Is there a similar function that takes
> only the expression that I want to factor out as argument?
Some approaches are:
*** factorsum(eq) => t*((y+x)^2+(b+a)^2)
But this can also expand things in some cases:
factorsum(q*(a*t+t)-q*t+(b+a)^2*t) => (a*q+b^2+2*a*b+a^2)*t
This may be good or bad, depending on your goals
*** t*multthru(eq/t) => t*((y+x)^2+(b+a)^2)
This approach depends crucially on the syntactic form of the expression. cf:
multthru(eq1/t)*t => t*(q*(a*t+t)/t+(b+a)^2)
I suppose you could do map(factor,eq1) first for at least some cases like
multthru(map(factor,eq1)/t)*t => ((a+1)*q+(b+a)^2)*t
What approach is best for you will depend on the form of your inputs, the
desired form of your outputs and (if the expressions are large or hard to
factor) your efficiency requirements.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Maxima