Justin Walker on Thu, 22 Jul 2004 18:38:54 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Constructing polynomials


Thanks, Karim,

I guess I have to plead guilty to aggravated density...

On Jul 22, 2004, at 1:18, Karim Belabas wrote:

* Justin Walker [2004-07-22 04:53]:
[snip]
In psuedo-code terms, I'd like to do something like

MyProc(a,b)=
{
    f(x)=(x+a)^b;
    for (i=1,limit, print(f(i)));
}

Is this (a) feasible; (b) not easy; (c) Forgetaboutit?

Why not:

  MyProc(a,b)=
  {
    f=(x+a)^b;
    for (i=1,limit, print(subst(f, x, i)));
  }

I did try this, but I was working with 't_SER', and subst groused at me: "non polynomial or series type substituted in a series". I could make
   subst(f,x,0*x)
work, but that's somewhat limited :-}. Is it possible to 'evaluate' a series at a constant in pari/gp?

? If you insist on defining a user function, then you can use

  MyProc(a,b)=
  {
    ( f(x) = (x+a)^b );
    for (i=1,limit, print(f(i)));
  }

[ which is more efficient using the standard GP parser ]

This, I'd never have figured out. For my purposes, it is the better alternative.

Why do the "()"s make it acceptable?

Thanks for your help!

Regards,

Justin

--
Justin C. Walker, Curmudgeon-At-Large  *
Institute for General Semantics | It's not whether you win or lose...
                                       |  It's whether *I* win or lose.
*--------------------------------------*-------------------------------*