Ruud H.G. van Tol on Tue, 30 Jan 2024 13:23:49 +0100


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

Re: eval bernpol



On 2024-01-30 13:03, Aurel Page wrote:
Dear Ruud,

You can directly compute the evaluated Bernoulli polynomial:

A285068(n) = denominator(3^n * bernpol(n,1/3));

In my 2.15.4 that doesn't work.
bernpol() returns a polynomial.


You can also revert the polynomial instead of evaluating at a rational:

A285068b(n) = denominator(subst(Polrev(Vec(bernpol(n))),'x,3));

That is indeed (50%) more effective.


And it made me find the (another 20% more effective) variant:

A285068c(n) = denominator(3^n * substpol(bernpol(n),'x,3));


On 30/01/2024 12:50, Ruud H.G. van Tol wrote:
Is this a canonical and effective way to use bernpol?

A285068(n) = my(x=1/3); denominator(3^n * eval(bernpol(n)));

? [ A285068(n) |n<-[0..20] ]
% [1, 2, 2, 1, 10, 1, 14, 1, 10, 1, 22, 1, 910, 1, 2, 1, 170, 1, 266, 1, 110]

If not, what are alternatives?

Thanks, Ruud