Re: Bug in Coefficient[ ]
- To: mathgroup at smc.vnet.net
- Subject: [mg16397] Re: Bug in Coefficient[ ]
- From: trif at ipm.marine.su
- Date: Thu, 11 Mar 1999 02:16:59 -0500
- Organization: Deja News - The Leader in Internet Discussion
- References: <7bt48t$n23@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <7bt48t$n23 at smc.vnet.net>, shimshim at mse.waseda.ac.jp (Mahoro Shimura) wrote: > Does anyone know why Coefficient[ ] does not work in > the follwing case? > > In[1]:= Coefficient[x[1]*x[2]^2,x[1]*x[2]^2] > > Out[1]= 0 > > Of course, this value must be 1. > > (I use Matematica Ver.3.0 for SPARC.) > > Thanks, > Mahoro Shimura > e-mail:shimshim at mse.waseda.ac.jp > > This problem was already discussed here: search the conf. archive by means, f.e., Dejanews. However, the function below does all things fine: In[1]:=myCoefficient[expr_,term_]:= Module[{c},ReplaceAll[expr,Plus[_.,Times[c_.,term]]:>c] ] In[2]:=myCoefficient[x[1]*x[2]^2,x[1]*x[2]^2] Out[2]=1 Cheers, Evgeni Trifonov Institute of Applied Mathematics, Vladivostok, Russia -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own