Post Reply 
(49G) Gauss Legendre 18 Point Integration
06-30-2014, 09:11 AM (This post was last modified: 06-15-2017 01:47 PM by Gene.)
Post: #1
(49G) Gauss Legendre 18 Point Integration
The programme returns the approx area under a curve between two given limits of integration.

A programme taking one real argument from the stack & returning a real result should be stored in "func".

The integer number of divisions from one upwards of the area to be integrated in "divs".

Lower & upper limits of integration in levels 2 & 1 of the stack.

::
CK2&Dispatch
2REAL
::
ARRY [
% .169142382963
% .164276483746
% .154684675126
% .140642914671
% .122555206711
% .100942044106
% 7.64257302549E-2
% .049714548895
% 2.16160135265E-2
]
ARRY [
% 8.47750130417E-2
% .251886225692
% .411751161463
% .559770831074
% .69168704306
% .803704958973
% .892602466498
% .955823949571
% .991565168421
]
BINT10
1LAMBIND
%3
ID func
TYPEREAL?
NcaseTYPEERR
%0
5PICK
5PICK
OVER
%-
'
ID divs
DUPSAFE@
ITE
::
FPTR2 ^DUPTYPEZ?
IT
FPTR2 ^Z>R
DUPTYPEREAL?
?SEMI
DROP
%1
;
%1
%1
%MAX
%IP
DUPROT
?STO_HERE
%/
ID divs
COERCE
ZERO_DO
2DUP
%+SWAP
%0
OVER
%2
%/
5ROLL
5PICK
%+
%2
%/
8ROLL
8ROLL
1GETLAM
ONE_DO
INDEX@
PULLREALEL
5PICK
%*
4PICK
2DUP
%+
ID func
SWAPROT
%-
ID func
%+
ROT
INDEX@
PULLREALEL
ROT
%*
6ROLL
%+
5UNROLL
SWAPLOOP
8UNROLL
8UNROLL
DROP
%*
4ROLL
%+
3UNROLL
LOOP
ABND
2DROP
5UNROLL
2DROP
xDROP2
;
;
Find all posts by this user
Quote this message in a reply
Post Reply 




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