Another, more efficient, way:
sublis(makelist(u=0,u,U),eq);
It might be nice to have some form of ratcoeff that picks out
particular terms, e.g.
ratcoeff( 2*x*y^2 + 3*x + 1, [x,y], [1,2] ) => 2
-s
On Dec 3, 2007 9:28 AM, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
> On Dec 3, 2007 4:20 AM, Adi Shavit <adish at eyetech.jp> wrote:
> > 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?
>
> Somehow I knew you were going to ask that.... The simplest way I can
> think of is
>
> block([res: eq], for i in U do res: subst(0,i,res), return(res))
>
> but there's probably a better way....