Max Alekseyev on Sun, 01 Oct 2023 04:12:06 +0200


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

Re: evaluation of Bernoulli polynomials


For me, this issue is just a matter of interface uniformity and convenience. 
I'd be happy if bernpol(k,a) can be computed faster than subst(bernpol(k),'x, a), but for the values I'm currently using it does not matter much.

Regards,
Max

On Sat, Sep 30, 2023 at 4:05 AM Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> wrote:
On Fri, Sep 29, 2023 at 09:06:16PM -0400, Charles Greathouse wrote:
> The implementation is straightforward:
>
> GEN
> bernpol_const(long k, GEN x)
> {
>   GEN C, S;
>   long i;
>   pari_sp btop;
>   constbern(k >> 1); /* cache B_2, ..., B_2[k/2] */
>   C = vecbinomial(k);
>   S = gen_0;
>   btop = avma;
>   for (i = 0; i <= k; ++i)
>   {
>     S = gadd(gmul(S, x), gmul(gel(C,i+1), bernfrac(i)));
>     if (gc_needed(btop, 1)) S = gerepileuptoint(btop, S);
>   }
>   return S;
> }

But would that be any faster than subst(bernpol(k),'x, a) ?
That is the point.

Cheers,
Bill.