(50g) Bernoulli polynomials
01-02-2019, 11:13 PM
Post: #15
 ttw Member Posts: 250 Joined: Jun 2014
RE: (50g) Bernoulli polynomials
I thought to try a slightly different approach to the Bernoulli Polynomials. These have several nice properties that make the easy to computer. I just keep the coefficients (as fractions in the code below, but these could be reals or numerator-denominator pairs) rather than the whole polynomial.

The procedure is based on the fact that each Bernoulli Polynomial has a simple integral (or differential from the other direction) relation with the next one in the series. The program operates in three steps. First the coefficients of the integrated polynomial are computed. Second these are normalized to have a leading coefficient of one. Third; the constant of integration is added such that the polynomial's integral is zero.

I use an auxiliary program that yields a list {1,2,3...N} when given N as an input. This is actually a program that I have written for every programmable calculator I have; it seems to occur rather commonly. I could just put this inline.

Program KSEQ: input N, output a list from 1 to N. (No check on illegal input.)

<< 1 SWAP FOR I I NEXT DUP ->LIST >>

The next program takes a Bernoulli Polynomial as input and updates it to the next higher polynomial. The flags are set for exact, non-umeric, and polynomials being 1+x... rather then ...x+1. Thereare three local variables (though these could be eliminated by clever stack usage; this didn't make things run faster though and was a bit harder to read.) Variable X is the list of coefficients; N is the length of the current polynomial (1 more than the index) and E is the index of powers of the polynomial.

<< DUP SIZE XQ 0 -> X N E <<
X N KSEQ DUP 'E' STO / N * EXPAND DUP E 1 ADD / {0} ƩLIST NEG SWAP + EXPAND >> >>
 « Next Oldest | Next Newest »

 Messages In This Thread (50g) Bernoulli polynomials - peacecalc - 12-17-2018, 05:31 PM RE: (50g) Bernoulli polynomials - DavidM - 12-17-2018, 06:07 PM RE: (50g) Bernoulli polynomials - John Keith - 12-17-2018, 07:03 PM RE: (50g) Bernoulli polynomials - DavidM - 12-17-2018, 08:37 PM RE: (50g) Bernoulli polynomials - ttw - 12-17-2018, 09:17 PM RE: (50g) Bernoulli polynomials - peacecalc - 12-17-2018, 10:03 PM RE: (50g) Bernoulli polynomials - ijabbott - 12-17-2018, 11:58 PM RE: (50g) Bernoulli polynomials - peacecalc - 12-22-2018, 11:06 PM RE: (50g) Bernoulli polynomials - John Keith - 12-23-2018, 07:58 PM RE: (50g) Bernoulli polynomials - peacecalc - 12-29-2018, 02:18 PM RE: (50g) Bernoulli polynomials - Albert Chan - 12-29-2018, 03:52 PM RE: (50g) Bernoulli polynomials - DavidM - 12-29-2018, 04:40 PM RE: (50g) Bernoulli polynomials - John Keith - 12-29-2018, 05:54 PM RE: (50g) Bernoulli polynomials - peacecalc - 12-30-2018, 01:44 PM RE: (50g) Bernoulli polynomials - ttw - 01-02-2019 11:13 PM RE: (50g) Bernoulli polynomials - peacecalc - 01-03-2019, 10:20 AM

User(s) browsing this thread: 1 Guest(s)