Newsgroups: comp.sys.hp48
From: bd628@torfree.net (Bill Markwick)
Subject: Revised Integration Front End
Message-ID: <Ev0ELA.ItE.0.queen@torfree.net>
Organization: Toronto Free-Net
X-Newsreader: TIN [version 1.2 PL2]
Date: Tue, 23 Jun 1998 14:51:09 GMT
Lines: 124
Xref: republic.btigate.com comp.sys.hp48:12397

INTG2 is a reworking of the integrator front end that I sent up about a
week ago. It's reduced to only two Input screens and has the same
features. Again, it can't integrate anything the HP48 can't, but it's
convenient (only two keystrokes if the defaults are okay).
 
The first screen asks for the lower limit (default 0), the upper limit
(default 'X'), and the variable of integration (default 'X'). You can
press Enter for these or edit them to what you want; if you enter the
name of a global variable for the upper limit, there's a caution
message.
 
The second screen asks for the integrand. You can press Enter for the
default (the contents of EXPR), enter your own, or press On,Enter to use
any algebraic that was in level 1 before you started the program (level
1 is copied, not cleared, so it reappears afterwards on level 2). This
Input screen will loop until it gets an algebraic or until it's
cancelled with two ONs.
  If you enter a new integrand, EXPR is overwritten. Remove the phrase
DUP 'EXPR" STO if you don't want this.
 
If the upper limit is a number, numeric mode is used; Fix 3 makes it
faster. If you want more accuracy at the expense of speed, increase Fix
3 and Rnd 3.
  If the HP48 can't handle a symbolic integration (such as sin(X)^2), a
message is displayed.
 
On exit, whether normal or an error, the stack and flags are returned to
the state they were in before the program started. The installed size is
935 bytes.
 
 
%%HP: T(3)A(R)F(.);
\<< DEPTH RCLF \-> DP
FL
  \<< -3 CF
    IFERR
"Edit or press Enter"
{
":Lower lim: '0'
:Upper lim: 'X'
:Variable:  'X' "
ALG V { 1 15 } }
INPUT OBJ\-> 3 \->LIST
1 * OBJ\-> DROP 2
PICK
      IFERR VTYPE 0
\>= {
"Limit variable
exists and may
cause errors."
MSGBOX } IFT
      THEN DROP
      END
      DO
        IFERR
"Input integrand,
Enter for default, or
ON,Enter to use stack:"
          IFERR
'EXPR' RCL
          THEN DROP
"'No EXPR exists'"
          END \->STR
{ { 1 0 } ALG } +
INPUT DUP "" == {
DROP 4 PICK \->STR }
IFT
          IFERR
OBJ\->
          THEN
"No EXPR exists.
Enter integrand
or ON,ON to
exit."
MSGBOX
          END
        THEN DEPTH
DP - DROPN
"Cancelled or
no suitable
integrand
on stack."
MSGBOX FL STOF KILL
        END DUP
'EXPR' STO DUP TYPE
9 == { DUP } IFT
      UNTIL TYPE 9
==
      END SWAP 4
DUPN ROT
      IF SAME
      THEN 2 DROPN
\.S OBJ\->
        IF DUP \->STR
"\.S" ==
        THEN
"Can't integrate
that
symbolically."
MSGBOX DOERR
        END 3 DROPN
EVAL COLCT
      ELSE 2 DROPN
3 FIX \.S
        IFERR \->NUM
        THEN FL
STOF
"Bad argument
error."
MSGBOX DEPTH DP -
DROPN FL STOF KILL
        END 3 RND
      END FL STOF
    THEN DEPTH DP -
DROPN FL STOF
    END
  \>>
\>>


-- 
- Bill Markwick,  Toronto, Ontario, Canada  -  BD628@torfree.net
  Visit the Folk File, a large online dictionary of folk music terms at:
          http://www.cgrg.ohio-state.edu/~spencer/FF/