Post Reply 
(50g) Bernoulli polynomials
12-17-2018, 05:31 PM (This post was last modified: 12-17-2018 10:10 PM by peacecalc.)
Post: #1
(50g) Bernoulli polynomials
Hello HP50g-fans,

I made a program for Bernoulli-polynomials ( = BP), it works with three equations:

\[ B_o(x) = 1 ~~~~~~~ \text{start}\]

\[ B_n(x) = n \cdot \int B_{n-1}(t)dt ~~~~~~~ \text{recursive definition}\]

\[ \int_0^1 B_n(t)dt = 0 ~~~~~~~~ \text{ calculate the constant from second equation}\]

Therefore we have polynomials it is easy to program and make use of CAS of the HP50g.
The program "BCALC" has to possibilities to work:

a) with one parameter "N", then it will calculate all BP from 0 to N, but it only stores the last N'th BP.

b) with two parameters "K" to "N". Let us say you calculated BP for N = 5, then you decide to calculate further on to N = 7. If you don't delete the global variables "BN1" and "BN2", you can input 6 and 7 and you get BP for N=7 from N = 5 as first equation.
That is a advantage in time, because the CAS operations are very slow.

To let the program know how many parameters I input, I use a list with one or two elements.

The program uses only one integration because the second one (stored in "BN2") prepares the BP for "N+1" (again time saving). I only make comments for the first part, I hope the rest of the program is understandable for you.


%%HP: T(2)A(R)F(.);
« OBJ->  
  IF 2. ==
  THEN \-> K N
    « K N FOR J 
            BN2 J * 'C' + EVAL DUP 'BN1' STO   @@RCL the prepared BP 
                                                            @@ and multiplied with J 
                                                            @@ add the constant "C" and stored
                                                            @@in BN1 temporally
            INTVX EVAL DUP 'BN2' STO            @@ integrated BP and stored
                                                            @@in BN2 temporally
            'X=1' SUBST EVAL 0 = 'C' ISOL DUP @@ set the upper limit 1 and calculate
                                                            @@ the constant "C"
            BN1 SWAP SUBST EVAL FDISTRIB   @@ RCL the BN1 und substitute the "C"
            'BN1' STO                                   @@ with its number and store it in BN1
            BN2 SWAP SUBST EVAL 'BN2' STO   @@ RCL the BN2 und substitute the "C"
                                                            @@ with its number and store it in BN2
                                                            @@ as the prepared BP of J + 1
  ELSE \-> N
    « B0 INTVX 'C' + DUP 'BN1' STO 
      INTVX DUP 'BN2' STO 
      'X=1' SUBST EVAL 0 = 'C' ISOL DUP

      IF N 1 > 
          2 N FOR J 
               BN2 J * 'C' + EVAL DUP 
               'BN1' STO INTVX EVAL DUP 
               'BN2' STO 'X=1' SUBST EVAL 0 = 'C' ISOL DUP 
               'BN1' STO 
               BN2 SWAP SUBST EVAL 
               'BN2' STO

Enjoy it and tell me your improvements and critics.

SORRY SORRY SORRY, dear Mr. Admin move this thread to "General Software Libary".

Find all posts by this user
Quote this message in a reply
Post Reply 

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 - DavidM - 12-17-2018, 08:37 PM
RE: (50g) Bernoulli polynomials - ttw - 12-17-2018, 09:17 PM
RE: (50g) Bernoulli polynomials - ijabbott - 12-17-2018, 11:58 PM
RE: (50g) Bernoulli polynomials - DavidM - 12-29-2018, 04:40 PM
RE: (50g) Bernoulli polynomials - ttw - 01-02-2019, 11:13 PM

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