Re: Coefficient problem
- To: mathgroup at smc.vnet.net
- Subject: [mg36452] Re: [mg36421] Coefficient problem
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Sat, 7 Sep 2002 02:54:14 -0400 (EDT)
- References: <200209060716.DAA11211@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
CeZaR wrote: > > Hi, > > Now I'm trying to calculate this formula: > > Delta[eq_, x_]:=Coefficient[eq, x]^2 - 4 Coefficient[eq, x^2] Coefficient[eq, x^0] > > eq has this form a x^2 + b x + c > > But there is a problem with the x^0 coefficient! > How can I overcome that? > > Thanks! > > CeZaR Coefficient cannot figure out who is and is not a variable when a "variable" of 1 is specified. To work around this you might instead do delta1[poly_, x_] := Coefficient[poly,x]^2 - 4*Coefficient[poly,x,2]*Coefficient[poly,x,0] I prefer instead to use CoefficientList: delta2[poly_, x_] := (#[[2]]^2 - 4*#[[1]]*#[[3]])& [CoefficientList[poly,x]] In[25]:= poly = a*x^2+b*x+c; In[26]:= delta1[poly,x] === delta2[poly,x] Out[26]= True Daniel Lichtblau Wolfram Research
- References:
- Coefficient problem
- From: pascal@go.ro (CeZaR)
- Coefficient problem