Another question please.
What if my eq has scalar elements too as in
eq: a*x+b*y+3*x+9*z-4;
Then how do I also extract the free variable, i.e. -4 in your example?
I can't define U:[x,y,z,1];
Please advise,
Thanks,
Adi
Stavros Macrakis wrote:
> If U is your list of unknowns, how about
> [ U, makelist(ratcoef(eq,ui,1),ui,U) ]
> ? This is with eq in the form of LHS-RHS, not LHS=RHS.
>
> Example:
>
> (%i1) eq: a*x+b*y+3*x+9*z-4;
> (%o1) 9 z + b y + a x + 3 x - 4
> (%i2) U: [x,y,z];
> (%o2) [x, y, z]
> (%i3) [ U, makelist(ratcoef(eq,ui,1),ui,U) ];
> (%o3) [[x, y, z], [a + 3, b, 9] ]
>
>
> More efficient if you convert eq to CRE form beforehand: eq: rat(eq,U).
> And more robust if you check that there are no non-linear terms. Word
> to the wise: a typo can convert linear to non-linear.
>
> -s
>
> On Dec 2, 2007 9:14 AM, Adi Shavit <adish at eyetech.jp> wrote:
>> I have a linear equation set of the form A*x+B*y+C*z +... = 0
>> A,B,C.. are my parameters and x,y,z... are the unknowns.
>> However, not all equations contain all unknowns.
>>
>> How can I split (or factorize) the equations into a vector dot product,
>> e.g. [a,b,c,...] . [x,y,z...] for use later in a numerical linear
solver of
>> the form Ax=0?
>