Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Re: Lists and polynomials

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71048] Re: [mg71023] Lists and polynomials
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Mon, 6 Nov 2006 02:53:00 -0500 (EST)
  • References: <200611050407.XAA21691@smc.vnet.net>

aland wrote:

>Hi All,
>Another beginner here!
>I am trying to create a list based around a polynomial.
>In particular, I want to work with a large-ish number based on a power
>of 2
>e.g.
>629 x^2  + 863 x + 271
>where x = 2^10
>What I want to do is take a number y such as y=6718213 and derive a
>list where the list values are the coefficients of the polynomial.
>So that if my number y=1027 (2^10 +3)
>the polynomial would be
>x+3
>and the list would be { 1,3 }
>
>I have tried NestWhileList[] and PolynomialRemainder[]  but I'm really
>struggling to get them to do what I want.  I have a procedural
>programming background; functional programming looks excellent, I just
>can't get it to work!
>
>Any suggestions (like you're using the wrong functions, try these
>others....) would be gratefully received.
>
>I'm also looking to convert the list back into a number once I've
>finished working with the polynomial.
>
>Mathematica v4.2, although it probably doesn't make a lot of
>difference.
>
>Thanks in advance,
>
>Alan
>  
>
If I understand your problem correctly, then the simplest solution is to 
use IntegerDigits and FromDigits:

In[1]:=
IntegerDigits[1027, 2^10]
Out[1]=
{1, 3}

gives the list you want, and:

In[2]:=
FromDigits[{1, 3}, 2^10]
Out[2]=
1027

converts back into your original number. You could even use FromDigits 
to convert to the polynomial form:

In[3]:=
FromDigits[{1, 3}, x]
Out[3]=
x + 3

Carl Woll
Wolfram Research


  • Prev by Date: Re: Workbench: get nb's into a project & compare them
  • Next by Date: Re: Factor.....
  • Previous by thread: Lists and polynomials
  • Next by thread: Re: Lists and polynomials