Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


  • Prev by Date: Re: Plotting The Slope field of a differential equation
  • Next by Date: Re: Fill the space surrounded by two contours lines with different colors
  • Previous by thread: Coefficient problem
  • Next by thread: Re: Coefficient problem