Chiel
Chiel

Reputation: 6194

Rearrange equation using Maxima

In Maxima I have an equation that is like:

eq : c0*a + d0*a + c1*b - c2*p - c4*q = c5*r

Is there a command that allows me to arrive at:

(c0 + d0)*a + c1*b = c2*p + c4*q + c5*r

In short, I want to choose which variables end on either the left or right hand side and I want to write it such that there is only one occurence of the variables I select (in this case a, b, p, q, r).

Upvotes: 2

Views: 1430

Answers (1)

Robert Dodier
Robert Dodier

Reputation: 17585

Perhaps coefmatrix is useful for this.

(%i1) display2d : false $
(%i2) eq : c0*a + d0*a + c1*b - c2*p - c4*q = c5*r $
(%i3) vars : [a, b, p, q, r] $
(%i4) coeffs : coefmatrix ([eq], vars);
(%o4) matrix([d0+c0,c1,-c2,-c4,-c5])
(%i5) coeffs . vars;
(%o5) (-c5*r)-c4*q-c2*p+a*(c0+d0)+b*c1

Note that both arguments of coefmatrix must be lists.

Upvotes: 2

Related Questions