Subject: How to help maxima get equation grouped nicely
From: Stavros Macrakis
Date: Sat, 20 Aug 2011 12:38:56 -0400
Something like this, perhaps?:
(%i13) A:a1+a2^2$
(%i14) B:b2/(1+b2)$
(%i15) foo:(q+p)$
(%i16) bar:(p+1/3)$
(%i17) baz:(p^3-1)$
(%i18) quux:(2*p-3*q)$
(%i19) expr: A*foo+A*bar+A*baz+B*quux;
(%o19)
(a2^2+a1)*(q+p)+b2*(2*p-3*q)/(b2+1)+(a2^2+a1)*(p^3-1)+(a2^2+a1)*(p+1/3)
(%i20) divide(expr,A);
(%o20) [(3*q+3*p^3+6*p-2)/3,-(3*b2*q-2*b2*p)/(b2+1)]
(%i21) divide(%[2],B);
(%o21) [2*p-3*q,0]
(%i22) A*%o20[1]+B*%o21[1];
(%o22) (a2^2+a1)*(3*q+3*p^3+6*p-2)/3+b2*(2*p-3*q)/(b2+1)
This works even if A, foo, etc. are not syntactic units:
(%i23) ratsimp(expr);
(%o23)
(((3*a2^2+3*a1-9)*b2+3*a2^2+3*a1)*q+((3*a2^2+3*a1)*b2+3*a2^2+3*a1)*p^3+((6*a2^2+6*a1+6)*b2+6*a2^2+6*a1)*p
+(-2*a2^2-2*a1)*b2-2*a2^2-2*a1)
/(3*b2+3)
(%i24) divide(expr,A);
(%o24) [(3*q+3*p^3+6*p-2)/3,-(3*b2*q-2*b2*p)/(b2+1)]
same intermediate result
And of course the factors can be reorganized:
(%i25) A*multthru(%o20[1])+B*%o21[1];
(%o25) (a2^2+a1)*(q+p^3+2*p-2/3)+b2*(2*p-3*q)/(b2+1)
On Sat, Aug 20, 2011 at 12:21, dlakelan <dlakelan at street-artists.org> wrote:
> On 08/20/2011 08:03 AM, dlakelan wrote:
> > Suppose I have an equation of the form:
> >
> > A*foo + A*bar + A*baz + B*quux
> >
> > how can I get maxima to reformat this as:
> >
> > A*(foo+bar+baz) + B*quux
>
> I should mention that A and B are not simple single variables but rather
> rational expressions of two variables which do not appear in foo, bar,
> baz, or quux
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>