       Re: change of a coefficient in a polynomial

• To: mathgroup at smc.vnet.net
• Subject: [mg44789] Re: change of a coefficient in a polynomial
• From: drbob at bigfoot.com (Bobby R. Treat)
• Date: Thu, 27 Nov 2003 11:38:13 -0500 (EST)
• References: <bpurvg\$oc7\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```I don't know if this is the obvious solution you don't want, or the
more flexible solution you DO want. Neither, maybe!

ClearAll[changeCoefficient]
changeCoefficient[poly_, x_, n_, target_] :=
Collect[poly + (target[Coefficient[poly, x]] -
Coefficient[poly, x, n])*x^n, x]

p[x_] := c + c*x + c*x^2

changeCoefficient[p[x], x, 0, -# &]
changeCoefficient[p[x], x, 0, 1 &]
changeCoefficient[p[x], x, 2, Sin]
changeCoefficient[p[x], x, 3, Sin]

-c + x*c + x^2*c
1 + x*c + x^2*c
c + x*c + x^2*Sin[c]
c + x*c + x^2*c + x^3*Sin[c]

Bobby

Paolo Bientinesi <pauldj at cs.utexas.edu> wrote in message news:<bpurvg\$oc7\$1 at smc.vnet.net>...
>
> assume you are given a polynomial
>
> p[x_] :=  c + c x + c x^2 ....
>
> and you want to generate a polynomial p1[x] from p[x]
> changing one coefficient only, like:
>
> p1[x_] := -c + c x + c x^2
>
>
> Is there any other way other than the obvious CoefficientList
> solution?
>
> Thanks

```

• Prev by Date: Re: Remote Display on Linux still unsolved !
• Next by Date: Re: Defining Operators
• Previous by thread: Re: change of a coefficient in a polynomial
• Next by thread: RE: change of a coefficient in a polynomial