       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 - 4*#[]*#[])&
[CoefficientList[poly,x]]

In:= poly = a*x^2+b*x+c;

In:= delta1[poly,x] === delta2[poly,x]
Out= 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