(04-01-2014 05:24 AM)peacecalc Wrote: first of all, I tried to include with the tags my program, but it doesn't works, the format was spoiled.
Everything works fine. The only exception are the comments that will not line up because you used tab characters. Which is always a bad idea since there is no standard that defines how many blanks will equal one tab. That's why you should always use blanks instead of tabs for such applications.
Without tabs everything looks fine:
Code:
%%HP: T(3)A(R)F(,);
\<< DUP2 - { }
\-> N O U H EL @@Locale Variables (# Iterations, upper, lower limit integration
@@ difference of limits, result list)
\<< O Y U Y + H 2, / * 'EL' STO+ @@Calc. T11
IF N 2, \>=
THEN @@Branch if more then one iteration
H DUP 2, / 0, U 1,
\-> HM HP YK XK K @@Local variables (h/2^(J-2), h/2^(J-1), Sum of trapezoid aeras,
\<< @@ argument for funct., Index for sum of funct.
@@ values)
1, N 1, - @@Outer loop from 1 to N-1
FOR J
'EL' @@load result list on stack
EL J GET @@load j-element of result list
HP 'XK' STO+ @@load first value for XK
1, K @@Inner loop from 1 to 2^J
START @@Calc. the sum of function values
XK Y 'YK' STO+
HM 'XK' STO+
NEXT @@End of inner loop
YK HM * + 2, / @@Calc. TJ1
STO+ @@and adding to result list
HP 'HM' STO @@Initializing locals for next iteration of outer loop
'HP' 2, STO/
0, 'YK' STO
2, 'K' STO*
U 'XK' STO
NEXT @@End of outer loop
EL N GET @@Reporting the value of trapez rule (can be left)
4, 3, \-> QZ QN @@Initializing locals for Richardson extrapolation
\<< 2, N @@Loop for Richardson extrapl.
START
EL 2, @@load result list on stack and parameter 2, (two elements)
@@for DOSUBS command
\<< QZ * SWAP - QN / @@Calc. a new TJL element TJL = (QZ*TJ(L-1)-T(J-1)(L-1))/QN
\>>
DOSUBS
DUP @@load result list of DOSUBS twice on stack (can be left)
'EL' STO @@store result of DOSUBS in EL for next iteration
4, 'QZ' STO* @@load new values for next iteration
QZ 1, - 'QN' STO
NEXT @@End of extrapolation loop
\>>
\>>
END EL OBJ\-> DROP @@Result of numerical integration
\>>
\>>
Dieter