home *** CD-ROM | disk | FTP | other *** search
-
-
-
- SJ Scientific presents
-
- an RPN based scientific
-
- calculating tool
-
-
- R RRRR PPPPPP NN NNN
- R R P P NN N
- R R P P N N N
- SJ . RRRRR PPPPP N N N
- R R P N N N
- R R P N N N
- R R P N NN
- RRR RR PRP NNN NN
-
-
- Written by J.I. Landman
- Copyright 1989,1990
- SJ Scientific
-
- (SJ Scientific is a partnership wholly owned by Sofia Villanueva
- and Joseph I Landman, whose purpose is the dissemination of tools
- useful for students/professionals using personal computers)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Table Of Contents:
- ++++++++++++++++++
-
- Page Description
- ---- -----------
-
- 3 Introduction
- 4 Program Description
- 5 System requirements
- 5 Legal Stuff
- 6 A Note to New Users
- 8 Starting Out
- 8 Program Usage
- 11 Function List
- 15 Ordering Info
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Introduction:
- =============
-
- RPN is a calculating tool written by J.I. Landman to be used
- primarily by scientists and engineers. RPN is basically a
- calculator, with quite a bit of power.
- RPN is a useful and powerful tool for those who regularly use
- Hewlett Packard calculators (such as the HP-42S, after which RPN
- was modeled), and wish a similar amount of functionality on their
- PC's.
- RPN is rather bland looking when first invoked. But looks
- aren't important. I am afraid that I am more interested in the
- utility of a tool than its appearance, as I would hate for my
- wonderful creation to sit unused but beautiful upon someone's
- machine. This might be changed in the future. But for the moment,
- I have attempted to make RPN be as user friendly/fault tolerant
- as possible.
- As well, RPN can do things that few other programs for a PC can
- do. RPN handles complex numbers in a transparent fashion, indeed
- it is intrinsically a complex number calculator. With 1 or 2 noted
- exceptions, ALL the functions that normally operate upon the set of
- real numbers have been extended and researched (in my handy dandy
- copy of "Handbook of Mathematical Functions" Abramowitz and Stegun)
- to deal with the complex plane.
- I am also intrigued by the possibility of a 1 word synonym
- replacing several commands. So I have included this within the
- program. The Synonym as it is implemented, is a wonderful thing.
- one may store useful numbers within it, as well as commands. More
- on this later.
- I have found the stack paradigm to be a useful tool in my
- calculating tasks, so I have implemented a simple stack of complex
- numbers, 16 entries deep. (8 of which are visible on screen).
-
-
-
-
-
-
-
-
-
-
- In all fairness, this calculator reflects my prejudices about
- computation in general. I find it suits most of my needs very well
- (I am a graduate Physics student). I hope that it will suit other
- physical scientists/researchers/engineers/students as well.
- Please do feel free to correspond with me about what you like
- or dislike, and what features you would like to see. I am very
- amenable to suggestions for improvement of this tool.
-
-
-
-
-
-
- Note: Within this document and my program, I make liberal use
- of the word RPN. I have explained the meaning of RPN, but
- I know not whom owns the copyrights (if any) to that word
- idea, etc.
- However... I do also use the words NOS TOS ... . These
- are ideas that I found within my HP-15C manual. Thus my
- very limited research leads me to believe that I should
- cite Hewlett Packard as the holder of copyrights for those
- ideas.
- Indeed the very inspiration for this program was my brand
- new HP-42s calculator. I very much wanted a similar program
- on my PC. So I wrote one.
- So I wish to thank HP for the terminology TOS,NOS, and for
- their marvelous calculating tools.
-
-
- (HP-42s, NOS, TOS are copyrights of Hewlett Packard Corp)
-
-
-
- What RPN was written in
- =======================
-
- RPN is written in MicroSoft QuickBasic version 4.5
- The choice of this language was rather simple, BASIC though
- scoffed at by so called professional programmers, is a powerful
- language. (since QB is NOT available on Vaxen and IBM mainframes
- I am beginning the process of porting this program to fortran,
- though I am investigating recoding it to live happily on the Vax)
- As a result of its beautiful debugging [Quickbasic]
- environment, I have been able to test the program to a very fine
- level. For each function I have added, I have checked MANY
- values in the real and complex plane against what is printed in
- A&S, and as well, against my HP-42s. I had found problems with
- several algorithms in A&S (well I wrote the code...), so I reworked
- the math as to correct them. There may yet be little critters
- hiding somewhere, but I have not found any recently... (yes I have
- been looking).
- I would be cautious in general about using functions near
- the limits of their domains. For example, from L'Hopitals rule
- we know that sin(x)/x goes to 1 in the limit of x approaching 0.
- RPN craps out around x=10^(-170) or so (thats 10.0d0**(-170) for
- the more fortranesq reader). But those who use RPN are quite
- familiar with the idea that one should be careful about dividing
- by very small numbers.
- For those interested, I am relying upon the built in
- emulator library, and thus have not coded the lower level function
- calls myself. I will try to put in taylor and asymptotic
- expansions in the near future, in an effort to increase the
- accuracy. I have replaced the old magnitude function to deal with
- the case of one component of the complex number being much larger
- than the other. I use an exact expression for 1 case, and a taylor
- expansion for the other. This gives more exact results in general.
-
- SYSTEM REQUIREMENTS
- ===================
-
- I recommend first of all some sort of IBM PC compatible computer.
- I have no idea whether this or any program compiled in QB will
- work on every compatible, or PC emulator (eg MacPC etc). I wrote
-
-
-
-
- this on my "souped up" PC (well, I have an 8087...)
-
- You will need 1 or more disk drives. A hard disk is fine, or a
- ram disk, etc. (I use my hard disk) A note: The program only
- reads or writes disks during diary operations.
-
- You will need some sort of display and adapter (not necessarily
- graphics).
-
- Most definitely you will need a keyboard, some electric current,
- and the desire to play with this program.
-
- Once you have this you are all set. Please do note, I will and I
- do assume a certain level of knowledge in mathematics and the use
- of PC's.
-
- The software can use the 8087 numeric coprocessor, or it will
- do a very nice job of emulating it if you do not have it.
-
- RPN needs at least 160K of main memory (RAM). It requires
- DOS 2.1 or higher (my machine uses DOS 3.3, but I used no advanced
- DOS functions).
-
- It does require an 80 column display so it will run on any of
- MDA,HGC,CGA,EGA, or VGA (my VGA works very well with it)
-
- You can see how versatile this program is already!
-
-
-
-
- A Note to new users.
- ____________________
-
-
- Scope and Domain of program
- ===========================
-
- The source code is not available, and the copy of the program
- you have is an unregistered evaluation copy. I place this program
- into the public domain, under the "Shareware" concept. That is if
- you find this program of utility for you or your work, then please
- do read on, otherwise, feel free to pass this along to several
- friends who may find some use for this sort of tool. I do encourage
- you to upload this to BBS's far and wide, intact (eg the way you
- downloaded it from a BBS, received it from a friend, etc).
- The scope of the program is that of an extensible complex number
- calculator. I will be adding features such as integration by
- various means, differentiation, etc, as soon as I recode this
- into fortran. It is USER EXTENDIBLE by using the SYNONYM command.
- This is EXTREMELY powerful (caps for emphasis!).
-
-
-
- GENERAL INFORMATION
- ====================
- (and legal stuff)
-
- i) Me
- I am a graduate student at Wayne State University
- studying Physics. I am working toward my PhD. (I have
- my masters as of June 1990).
- Being a graduate student, I am living on the miserly
-
-
-
-
- pittance given by the university for many hours of hard
- labor. Thus the MANY months of development time I have
- put into it are worth quite a bit to me, and they should be
- to you as well.
-
- So If you need to contact me for ANY reason...
-
- My school mail box
- J. Landman
- Graduate Student,
- Physics and Astronomy Dept, Physics Bldg,
- Wayne State University,
- Detriot, MI 48202
- (313)-425-5159 (voice)
- landman@msupa.bitnet
- landman@msupa.pa.msu.edu
- 07480jln at MSU
- 07480jln@msu.bitnet
- msuhep::landman
-
- ii) You
- You are free to use and copy this program and
- documentation, provided you distribute all the original
- files, and make no alterations to them. If you wish to use
- this in a corporate, or laboratory environment, you
- must arrange for a site license from SJ Scientific.
- The rates are:
- $12.50 for the first 2 computers.
- $10 for each additional computer over the
- initial 2.
- (considering the cost of a new calculator this is quite good)
- If you find this program to be of utility for your work,
- I would encourage you to contribute to my efforts, and
- and register this copy of RPN, as your conscience would
- bother you for the rest of your days if you did not...
- If you would be interested in receiving the latest
- version
- of RPN, please send me a blank formatted disk, a large
- Self Addressed Stamped Envelope, and $10.00 in the form of
- a check or money order (to cover my overhead, $12.00 if you
- do not have a disk, $15.00 if you do not have an envelope
- either). Obviously, I will register you as a user.
-
-
- iii) Registration
- If you wish to register yourself as a user of the
- program, then please send me your name, address, phone
- number, and $12.50. This entitles you to the latest
- version of RPN. If you are seeking a site licence, then
- you must register each copy of the program as noted above.
- (see "ii").
- I will attempt to provide upgrades at more or less a
- quarterly basis. It may be more frequent, it may be less,
- depending upon my schedule of classes, research, etc. I
- make no guarantees as to the frequency or number of
- updates.
-
- iv) Where I am going with all of this
- I am targeting this program for the people studying
- physical sciences and related topics. I am VERY open to
- suggestions. So please feel free to comment.
-
- If you find or write useful synonym libraries (or useful
- diary files), I would be happy to include them in the
- utility files of the distribution.
-
-
-
-
-
- v) Liabilities
- See the other document file within this package.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Now for useful things...
-
-
- STARTING OUT (running the program)
- ============
-
- Somehow place RPN into the default directory. This can be
- accomplished any number of ways.
-
-
-
-
- for a hard disk system, if the program is in C:\RPN
- type CD \RPN <enter>
- for a floppy drive system, first make sure you have RPN on the
- diskette in the default drive.
- for example if RPN is on drive B,
- type B: <enter>
-
- Now type RPN <enter>. Where
- <enter> is the enter/return key. You are now in the program.
-
-
-
- USING RPN
- =========
-
- 1) How to enter expressions
-
- RPN is a notation developed by a Polish Mathematician in order to
- simplify computation and order of operations. It is also called
- postfix by computer science types. Hewlett Packard calculators
- are famous for their implementation of postfix.
- We are used to a notation called infix where operators (such as
- +,-,/,* etc) are placed between 2 numbers. For example 1 + 1.
- As well, on most infix calculators (such as TI, Panasonic,
- Sharp, etc) you may form very complex expressions with the use of
- parenthesis'. For example ((( a + b )^(3/2))(F(x))
- To enter the equivalent RPN expression, you would enter the
- following line at the prompt.
-
- a b + 3 2 / ^ F(x) * <enter>
-
- ( <enter> is the enter or return key on your keyboard )
- This has a simple interpretation. Read from left to right. Push
- numbers onto the stack, and operators operate upon the first 2
- elements of the stack.
- So "a b +" pushes a, then b onto the stack. Then it applies the
- addition operator which takes the stack top (TOS) and adds it to
- the next element in the stack (NOS). Then it pops the stack, and
- replaces the top of the stack with the sum that it computed.
- "3 2 /" pushes 2 then 2 onto the stack, then divides the NOS (the
- 3) by the TOS (should be 2).
- " ^ " takes the next on stack to the power of top of stack, and
- pops the stack.
- "f(x) *" pushes f(x) onto the stack, then multiplies to produce
- the final result.
- Do note that this is NOT the only way to use the RPN notation for
- this problem. For example, let us assume that x,y,z,t are synonyms
- for certain numbers. Suppose I had to add all of the numbers
- together
- for my operations. We could type
- x y z t + + +<enter>
- or
- x y + z + t +<enter>
-
- or
- x y z + + t +
-
- Polynomials are rather easy to enter using Horners rule.
- 2 3 4
- let f(x)=a + a * x + a*x +a *x + a *x
- 0 1 2 3 4
- we can rewrite this as
-
-
-
-
- f(x)=a + x*(a + x*(a + x*(a +x*a )))
- 0 1 2 3 4
- or using RPN
-
-
- a4 x * a3 + x * a2 + x * a1 + x * a0 +
-
- by now you have the basic idea!
-
-
-
- COMPLEX NUMBERS:
- RPN handles complex numbers in a transparent fashion. To enter
- complex numbers, note the following: Let a,b be real numbers.
- a complex number is entered into RPN as follows: a+bi
- "i" is the indicator of a complex part of a number.
- Allowable variations are as follows
- a or b: Real numbers
- ai or bi: Imaginary numbers
- a-bi: complex numbers
- -a+bi: " "
- -a-bi: " "
-
- example:
- to get 0+1i (better known as i) as the display, type
- -1 sqrt <enter>
- or
- 1i
-
- to enter 1+5i + 3-4i type
- 1+5i 3-4i + <enter>
-
-
- Editing:
- --------
- I have written a simple line editor for RPN input. It allows
- the arrow, function, escape, insert, and delete keys to be used.
- Pressing the up or down arrow after some RPN commands have been
- entered, scrolls back through the command buffer, also 16 elements
- deep. The Insert and delete keys perform as expected, and the
- backspace functions as a true backspace. The left and right
- arrows move you around on the command line to allow corrections
- etc. The escape key erases the current command input line, or
- while executing long synonyms or files, terminates their
- execution. The function keys perform the indicated operations. I
- like it (and it was one bear to debug!), and I hope you do as
- well.
-
- Error Messages:
- ---------------
- I worked awful hard to get useful error messages to the user.
- The error handler reports the error number and the problem (If
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- it understands it...) So far I have been successful at identifying
- what errors are caused by what process. If you encounter one that
- simply gives the error number and no message, then please let me
- know the circumstances of the problem, that I may investigate. The
- System is very fault tolerant.
-
- 2) FUNCTION LIST
-
- USAGE: simply type the name, and unless otherwise noted the function
- will act on the top of the stack. The results are left in the
- Top Of Stack (eg TOS).
- (commas separate synonymous commands)
-
-
- a) Basic math operations (C# = Complex number, R# = Real number)
- ===================== (TOS = Top Of Stack, NOS = Next On Stack)
- this notation is from the HP 15c users
- guide published by HP. (tm Hewlett
- Packard). The notation is compact and
- convenient.
-
- operator description of operation
- -------- ------------------------
-
- + addition (TOS+NOS)
-
- - subtraction (NOS-TOS)
-
- * multiplication (TOS*NOS)
-
- / division (NOS/TOS)
-
- ^ exponentiation (NOS^TOS)
-
- ! factorial (TOS)
-
- !! double factorial (TOS)
-
- 1/X,INV inversion (TOS)
-
- ABS Absolute magnitude (TOS)
-
- CONJ,~ complex conjugate (TOS)
-
- EXP exponentiation (TOS)
-
- LN natural log (TOS)
-
- LOG base 10 log (TOS)
-
- MAG magnitude of C# (TOS)
-
- ARG argument of C#
-
-
- NEG,-1*,NEGATE,NEGATIVE negate both imaginary and
- and real parts (TOS)
-
- RNEG negate real part (TOS)
-
- SQRT,ROOT square root (TOS)
-
-
-
-
-
- SWAP swap TOS and NOS
-
- CSWAP swap the real and
- imaginary parts (TOS)
-
- FIX set the number of digits
- in the decimal
-
-
- b) Trigonometric Operators
- =======================
-
- operator description
- -------- -----------
-
- ACOS,ARCCOS Inverse cosine (TOS)
-
- ASIN,ARCSIN Inverse sine (TOS)
-
- ATAN,ARCTAN,ATN Inverse tangent (TOS)
-
- COS,COSINE cosine (TOS)
-
- SIN,SINE sine (TOS)
-
- TAN,TANGENT tangent (TOS)
-
-
- c) Hyperbolic Operators
- ====================
-
- operator description
- -------- -----------
-
- ACOSH,ARCCOSH,INVCOSH Inv Hyperbolic cosine (TOS)
-
- ASINH,ARCSINH,INVSINH Inv Hyperbolic sine (TOS)
-
- ATANH,ARCTANH,INVTANH Inv Hyperbolic tangent(TOS)
-
- COSH Hyperbolic cosine (TOS)
-
- SINH Hyperbolic sine (TOS)
-
- TANH Hyperbolic tangent (TOS)
-
-
-
-
-
-
-
-
-
-
-
- d) Constants
- =========
-
- operator description
- -------- -----------
- a0,ab,abohr Bohr Radius in meters
-
-
-
-
-
- c speed of light in m/s
-
- e electronic charge in
- coulombs
-
- ev Electron Volts in c/m
-
- h Plancks constant in J s
-
- hbar Diracs constant (h/(2 pi))
-
- pi 3.14159265....
-
- euler Eulers constant
-
-
- e) System Commands
- ===============
-
- operator description
- -------- -----------
- DIARY saves a diary of commands
- to disk
-
- QUIT,EXIT terminate session and
- return to dos
-
- READ DIARY filename.ext reads a diary file from
- disk of the name
- filename.ext
-
- REFRESH Toggles the refresh flag to
- allow/disallow refreshing
- the stack display after
- every operation.
- The default is to see every
- operation. This is a bit
- slow, but it is fun to see.
-
-
- SYN,SYNONYM command synonym creates a synonym in
- memory, for the entry
- 'command'. When the parser
- encounters the entry
- 'command', it replaces it
- with the string of
- operators or numbers
- found in the synonym.
-
- eg SYN F sqrt sqrt defines F as the 4th root
-
- YOU MAY OVERRIDE THE INTERNAL
- FUNCTIONS WITH A SYNONYM!!!!
- SYN- removes a synonym from
- storage.
-
- STORE,STO synonym element_of_stack will store the contents of
- stack pointed to by the last
- number into the synonym.
- If synonym does not exist,
- then it is created.
- eg STORE x 3 will store the 3rd element of
- the stack into synonym x. To use the
- value stored into x, just type x where
- you need it!!!
-
- UNFORMAT toggles the formatted and
- unformatted modes of numeric
- display. to force 7 digits
- of decimal display from the
- unformatted display, you
- must do the following.
- UNFORMAT FIX 7
- to flip back to an
- unformatted display, just type
- the unformat command.
-
-
-
- 3) DESCRIPTION OF SYSTEM OPERATORS
-
- Before I get deeply involved into this description, I must make
- a note to you that all of the numerical operators with the
-
-
-
-
- exception of the Summation operator, are operable on the entire
- complex plane. This obviously includes the real axis, and
- imaginary axis. The other rather obvious exception to this is the
- inverse of 0 (or 0+0i). I will work on some method for properly
- handling infinities as they crop up.
- Constants push themselves onto the stack. They are usually real.
-
-
- DIARY:
- ======
- Diary saves every command that you type in to an ascii file
- of your own designation. These files are editable by any word
- processor capable of reading ascii files (obviously). You may
- change them as you wish, to include more or fewer operations.
- I would strongly advise against including any system level commands
- with the exclusion of SYN, or REFRESH.
-
- EXIT or QUIT:
- ==== =====
- EXIT or QUIT are very simply the methods of leaving RPN to DOS.
- There is no difference between then, just a matter of preference
- as to what you use.
-
- READ DIARY filename.ext:
- ========================
- READ DIARY filename.ext reads the diary files created by DIARY,
- or by your own word processor. The files are simply series of
- operators, numbers or commands. As each line of the file is read,
- it is displayed at the bottom of the screen (where you normally
- enter the commands). This simple interpreter will be extended in
- future releases.
-
- SYN or SYNONYM command synonym:
- === ========================
- SYN or SYNONYM command synonym places the single word command
- into the synonym look up table. When the parser encounters this
- word command, the parser replaces the word command by the string
- synonym. If entered on one line, then the synonym is assumed to
- be the rest of the line after command. An example.
- SYN ADD +
- will put the command ADD in the synonym list. To use this new
-
-
-
-
-
-
-
-
-
-
-
-
- synonym, we simply include it in the input line. For example...
- 1 1 ADD
- will be interpreted as "1 1 +" by the parser.
- Synonyms may be very complicated. For example.
- SYN F LN 1/X NEG EXP
- (this function F has the interesting property that F(F(x)=x,
- Synonyms may contain numbers and other synonyms.
-
- WARNING!!! DO NOT ATTEMPT TO MAKE RECURSIVE DEFINITIONS OF
-
-
-
-
- SYNONYMS!!!!
- eg do NOT attempt the following unless you wish to terminate the
- execution of the synonym by pressing <escape>.
-
- eg:
- SYN R1 1 + R1
- This does the following. pushes 1 onto the TOS. Adds the NOS to
- TOS and pops the stack, placing the sum in TOS. Then the parser
- expands the synonym R1 (eg self referent) and executes that... ad
- nauseam.
- This will simply never stop executing until you press the escape
- key.
- The length of synonyms should be kept to 80 operators or less.
- If you have a need for more, please send me a letter, and I will
- recompile the parser to accommodate it.
-
-
- SAVE object filename.ext
- ========================
- This command saves the object to filename.ext Object can be
- the 1st 3 letters of STAck, SYNonyms, or BOTh. This command
- writes a diary file out to disk, and can be read back in to restore
- a session by using READ DIARY filename.ext.
-
-
- NOTE: In the event of file name collision, RPN will ask you if you
- wish to Append to the existing file of the same name you had
- specified, or simply overwrite it. If you wish neither, simply
- press enter. Append is much safer than Overwrite, in that you may
- recover from mistakes.
-
-
-
-
-
-
-
-
- tm=trademark
-
- (1) HP42s,HP15c, etc tm Hewlett Packard Corp,
- (2) TI55 etc tm Texas Instruments Corp.
- (3) Panasonic tm Panasonic Corp.
- (4) Sharp tm Sharp Ltd.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Ordering Info
-
- Name:_____________________________________________________
-
- Company:__________________________________________________
-
-
-
-
-
- Title:____________________________________________________
-
- Dept:_______________________ office num:____________
-
- Street:___________________________________________________
-
- City:_______________________ State:_____________ Zip:_________
-
- st
- I would like to register _____ copies of RPN at $12.50 for the 1 2,
- and $10 for each
- additional copy.
-
- I have enclosed a check or money order for $______
- made out to Joseph Landman, or Sofia Villanueva.
-
- Mailing address:
- Physics and Astronomy Building,
- 666 Hancock Avenue,
- Wayne State University,
- Detriot MI 48202
-
- Comments:
- (please include so that you will help us to improve our product,
- and better meet the needs of our users!)