12-17-2018, 05:31 PM
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.
Enjoy it and tell me your improvements and critics.
SORRY SORRY SORRY, dear Mr. Admin move this thread to "General Software Libary".
greetings
peacecalc
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.
Code:
%%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
NEXT
»
ELSE \-> N
« B0 INTVX 'C' + DUP 'BN1' STO
INTVX DUP 'BN2' STO
'X=1' SUBST EVAL 0 = 'C' ISOL DUP
BN1 SWAP SUBST EVAL 'BN1' STO
BN2 SWAP SUBST EVAL 'BN2' STO
IF N 1 >
THEN
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 SWAP SUBST EVAL FDISTRIB
'BN1' STO
BN2 SWAP SUBST EVAL
'BN2' STO
NEXT
END
»
END
»
Enjoy it and tell me your improvements and critics.
SORRY SORRY SORRY, dear Mr. Admin move this thread to "General Software Libary".
greetings
peacecalc