| Karim Belabas on Thu, 22 Jul 2004 19:23:04 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Constructing polynomials |
* Justin Walker [2004-07-22 18:39]:
> I guess I have to plead guilty to aggravated density...
you're welcome.
> 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)));
>>>}
>>
>>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?
subst(truncate(f), x, C)
>>? 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)));
>> }
>
> This, I'd never have figured out. For my purposes, it is the better
> alternative.
>
> Why do the "()"s make it acceptable?
I've made a new FAQ entry :-).
http://www.math.u-psud.fr/~belabas/pari/doc/faq.html#funinfun
In short: the code within parentheses is evaluated first.
Cheers,
Karim.
--
Karim Belabas Tel: (+33) (0)1 69 15 57 48
Dep. de Mathematiques, Bat. 425 Fax: (+33) (0)1 69 15 60 19
Universite Paris-Sud http://www.math.u-psud.fr/~belabas/
F-91405 Orsay (France) http://pari.math.u-bordeaux.fr/ [PARI/GP]