Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*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 2003

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

Search the Archive

RE: change of a coefficient in a polynomial

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44793] RE: [mg44772] change of a coefficient in a polynomial
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Thu, 27 Nov 2003 11:38:17 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: Paolo Bientinesi [mailto:pauldj at cs.utexas.edu]
To: mathgroup at smc.vnet.net
>To: mathgroup at smc.vnet.net
>Subject: [mg44793] [mg44772] change of a coefficient in a polynomial
>
>
>Second question about polynomials:
>
>assume you are given a polynomial
>
>p[x_] :=  c[0] + c[1] x + c[2] x^2 ....
>
>and you want to generate a polynomial p1[x] from p[x]
>changing one coefficient only, like:
>
>p1[x_] := -c[0] + c[1] x + c[2] x^2
>
>
>Is there any other way other than the obvious CoefficientList
>solution?
>
>Thanks
>--
>Paolo
>
>pauldj at cs.utexas.edu		        paolo.bientinesi at iit.cnr.it
>


Paolo,

as I have no idea of what you want to attain (what does that operation mean
in mathematical terms? has that something to do with polynomials at all?),
so reasonable advice is difficult; some comparison for your choice:
 
In[1]:= p[x_] := SeriesData[x, 0, Array[c, {10000}, {0}]]
In[2]:= p1[x_] := p[x] /. c[5000] -> somethingelse
In[3]:= Coefficient[p1[x], x, 5000] // Timing
Out[3]= {0.651 Second, somethingelse}
In[4]:= p1[x]; // Timing
Out[4]= {0.1 Second, Null}
 
In[5]:= q = p[x];
In[6]:= q1 = q + (somethingelse - Coefficient[q, x, 5000]) x^5000; // Timing
Out[6]= {0.491 Second, Null}
In[7]:= Coefficient[q1, x, 5000] // Timing
Out[7]= {0.571 Second, somethingelse}
In[8]:= q1; // Timing
Out[8]= {0.01 Second, Null}
 
In[9]:= cf = CoefficientList[q, x]; // Timing
Out[9]= {0.641 Second, Null}
In[10]:= cf[[5001]] // Timing
Out[10]= {0.01 Second, c[5000]}
In[11]:= cf1 = ReplacePart[cf, something, 5001]; // Timing
Out[11]= {0.02 Second, Null}
In[12]:= cf1[[5001]]
Out[12]= something

--
Hartmut Wolf


  • Prev by Date: Re: Table format gets lost while write to outputfile?
  • Next by Date: Re: IO-Performance of Mathematica 4.1
  • Previous by thread: Re: change of a coefficient in a polynomial
  • Next by thread: Bad Command or FIlename (v2.2.2DOS)