use rpl for deriving rpl functions



#16

Hi folks,

I try something well-known in an old style. I want to give you an explanation for that little project.

I tried this in another hp-forum, but there I got there the message:
Say clearly what you want or show a solution of a problem.
Project with unconcrete aim or solution are not desirable.

Please, understand me right, I don't want fora-bashing, I accept
that opinion about the forum-style, so I decided to try here a new attempt.

It's a forum in "old calculators", I have a hp 50g, a new one. But I think, may be it's a theme for this forum, too.

Shortly: RPL/RPN versus algebraic style.

I think a lot of members here are very fond of RPN/PRL (of course).
But the CAS on the HP 50g (and former models) works with the algebraic form of mathematical terms for simplifiying or transforming these terms. Indeed even most fans of RPN/RPL think in algebraic patterns, when they do symbolic algebra (with paper and pencil or even with the hp calculators).

So my project is an effort to use only RPN (programmed in RPL), even in that symbolic algebraic calculations. By the way that is my justification to bring this theme in that forum: we old fashioned boys (and some girls of course, too) like to use RPN everywhere in mathematics (maybe it's not possible).

Please don't discuss wether it is useful or not. It is not serious, it's a game!

What is the beginning: I want to derive an rpn-function without any way through the classical algebraic patterns (which is the normal use on hp calculators, 39/40 and 50g).

What I have: I can transform every (of course not every, but a lot of) algebraic term into a RPN/RPL function.

So I found an article in the web (ten years old), which shows a very clear way to implement the derive-rules (a look-up table has to be nessary,too) in an recursive function.

Other projects can be: integration or the whole bunch of instruments (factorizing, collecting and so on...

When I (or some of you (may be) did this before) succeed in doing this, then HP has an new challenge for a new calculator for the old purists.

sincerely
peacecalc


#17

I abandoned book formulas when I got my original HP35. I changed to keystroke routines with easy to remember "formulas" all rearranged from the book versions. I squared equations to remove the root sign and moved all terms to the left side = 1. Thus I could multiply terms and invert to find the missing term. I found relations not shown in books as I could play with numbers easily. It may not be higher math but engineering shortcuts to answers.
RPL programming is too steep a hurdle for me now. Sam

#18

I have no idea what you're asking for.


#19

It's a bit hard to follow (perhaps lost in translation), but I think Sam gets it. Maybe Peacecalc wants to re-write algebraic expressions in RPN format (as Sam says he did many years ago), but use the 50g to manipulate them in programs. He wants to know if Forum members are interested in this.


#20

So, for example, a physics text that lists the equation

E Enter m Enter c 2 ^ * =

I guess I don't get it, or see the point. When you see an equation written the normal way, you instantly can "translate" it to how you'd enter it in RPN (maybe the reverse isn't true). It's not a truly new way of thinking about things (which his post seems to imply); you wouldn't "derive" things any differently than you otherwise would; it's just a different notation.

#21

I"m having some trouble understanding what you're trying to do also. It looks like you aren't a native English speaker. You may want to post in your native language and then maybe someone more familiar with English can translate. Alternatively, post an example of what your input and output should be.

Are you asking about doing symbolic derivatives? The 50g already does this, but I agree it would be a fun project anyway.

By the way, internally, algebraic expressions are stored in RPN form if I recall. So '3+3*5' is stored as 3 3 5 * +, so applying the symbolic rules for derivatives is pretty easy. But I'm not sure if you could do this in User RPL because I don't know if there's a way to extract the components of the algebraic expression.

You'll find that this is a friendly and helpful group here.

Dave

#22

So, do I understand that you want to develop a CAS that uses formulas in RPN format?

e.g. intead of:
INTVX(X^2*LN(X)) = 1/3*X^3*LN(X)+(-1/9)*X^3
you want:
INTVX(X 2 ^ X LN *) = X 3 ^ 3 / X LN * X 3 ^ 9 / NEG +

is that correct?


#23

Hello folks,

thank you for your replies.

First of all: I have to observe that my english abilities are more low-grade, then I thought (that's right: I'm not a native speaker).

I've learned that the book format is the same as what I call: algebraic terms. Book format is better,
because f. e.: x y z ^ * is also an algebraic term (in RPN format).

With derives i meant "symbolic derivatives".


I try it a second time to explain what I want. Maybe some observations are helpful:
The HP 50g needs relativly a long time for the function SUBST on a formular in book format compared
with the formular transformed in a function in RPN format
and the substituting variable is the variable of the function.


For example:
2: (x + 3*y)/(x^2 - 17)

1: x = 6 SUBST

takes more time for calculating then:

A function f is defined as:

<< -> x << x y 3 * + x 2 ^ 17 - / >> >>

1: 6 f

Of course the SUBST command is more general acting like the other way (for y you have to build a new function).
The conversion of a formular from book format in a rpn function is no problem: You need the little program "->RPN" in the
Advanced User Reference for the HP 50g on page 2-27. Then it's easy to build a function f (with USER RPL) mentioned above.

But the point is: You always get a result in book format:

(6 + 3*y)/19

My assumption is/was that the transformation between book and RPN format is an overhead which makes the symbolic calculations slow.
I also assumed that the hp 50g works internally with "trees" which represent the algebraic terms. I thought this was necessary
doing symbolic algebra and showing the book format.

If you have a list of an algebraic term in RPN format you needn't such a "tree", only a stack for storing the results in between.
That is a good condition for calcs with an infinit large stack. You use the serial order and the type of operators which are given in
RPN format. And you can do this also for symbolic algebra directly f. e.: symbolic derivatives.

The information of David Hayden is interesting: the book format is stored in RPN format. If it is possible to get an access (with user rpl) to that
storage places, than it is not necessary to make that conversion from book to RPN format.

for example: Input: { x 3 ^ 5 x 2 ^ * + } recursive function output: { 3 x 2 ^ * 5 2 x * * +}

One more assumption: some sophistcated functions, like "SERIES" could run faster (now may be, is sys rpl necessary).

Please tell me wether things become clear/clearer or not. I thank you for the time you've invested understanding my post(s).

Yes Bart that's what I want with a little correction:

1: X 2 ^ X LN * INTVX

1: X 3 ^ 3 / X LN * X 3 ^ 9 / NEG +


sincerely
peacecalc


#24

So, it's just about speed?

I don't think the speed issue is due to it being RPN versus textbook. When you try 6x+1, x=2, SUBST, I'm guessing what happens is the interpreter goes through each bit at a time

6? No, that's not x.
x? Yup, that's x, replace it with 2.
+? Not x
1? Not x, either.

And you get 6*2+1


Well, maybe you could argue that it is in fact an RPN versus textbook issue, because in RPN mode, it knows 6 automatically means "pop 6 onto the stack" and x means "pop whatever value x has onto the stack". It doesn't need to scan and compare.

However, it seems to me that in this case, you could just optimize your programs for speed; you don't need to change the way the calculator deals with every expression it's given (which is what it sounds like you want). I've dealt with that in the past. The first time I solved the general quartic equation on the 50g, I found it was fastest to deal with stack commands. That was able to solve the general quartic, symbolically (though it also worked with numerical input) in about 3 minutes, which I thought was impressive.

Even at the time, though, I knew something unintuitive: It is MUCH faster to take the squareroot of x with squareroot(variable) variable=x SUBST, than it was to simply enter x squareroot in RPN. The reason is that taking a squareroot directly on the stack causes an EVAL, and if the squareroot is of a complicated algebraic equation, the EVAL can take some time. On the other hand, the SUBST just plugs the expression into the squareroot symbol.

I later got it down to about 10 seconds I didn't use any algebraic expressions, but I still used SUBST.


#25

Hello crawl,

thank you for post, I haven't ignored it, but I followed your links, and I need some time understanding them. I will implement your programs in my hp 50g, too. Thank you very much.

It's not only efficiency, but I'm interested in understanding how the things work (or if they are possible or not). Even I know now, that the hp 50g works internally in RPN format. I like to program in RPL how it works to differentiate from an RPN input to an RPN output.

The HP guys were faster again with that topic.

Sincerely
peacecalc

#26

The HP RPL calculators store algebraic expressions in RPN internally. They are converted from algebraic to RPN on input, and from RPN to algebraic on output (display). All computations are done with them in RPN form internally.


#27

Hello Eric,

if that is true what you wrote (I have no reason for disbelieving this fact), then the "internal workflow" of the hp 50g is really optimized. The overhead then is only given by transforming book to rpn format and vice versa. Is a function with a book term also stored as an rpn formula by DEF or DEFINE?

Edited: 17 Nov 2011, 2:22 p.m.


#28

User-defined functions created by DEF or DEFINE with an algebraic store the algebraic object wrapped in a program into a variable, but the actual algebraic object is internally stored in RPN.

#29

So would it be possible to bypass the algebraic->RPN conversion and call the functions (with and RPN expression as input) using SysRPL?


#30

Yes, you can call a DEFINEd function from SysRPL, the same way that you would call any RPL program. A DEFINEd function *is* an RPL program.

The conversion to/from algebraic notation ONLY happens when the user is entering the algebraic expression, or it is being displayed to the user. Internally everything, including "algebraic objects", are stored in postfix (RPN) form. There's nothing special you need to do to bypass any conversion.


Edited: 18 Nov 2011, 3:17 p.m.


Possibly Related Threads...
Thread Author Replies Views Last Post
  Writing RPL programs on OS X Sean Freeman 18 2,335 11-30-2013, 03:59 PM
Last Post: Sean Freeman
  48G vs 49G+ User RPL Speed Comparison John Colvin 7 1,072 11-16-2013, 10:07 PM
Last Post: Han
  RPL 32 David Hayden 4 886 11-11-2013, 11:34 AM
Last Post: David Hayden
  [41CL] New Extra Functions version Monte Dalrymple 0 513 11-08-2013, 04:32 PM
Last Post: Monte Dalrymple
  HP Prime: in need of help with defining functions Alberto Candel 14 1,910 10-27-2013, 10:48 AM
Last Post: Alberto Candel
  HP Prime spreadsheet functions SanS 0 1,053 10-04-2013, 04:23 AM
Last Post: SanS
  Stats functions on the HP34S Nicholas van Stigt 5 896 09-24-2013, 02:45 AM
Last Post: Nick_S
  HHC / HP Museum Programming Contest for RPN and RPL machines Gene Wright 18 2,228 09-22-2013, 09:39 AM
Last Post: Miguel Toro
  Trig Functions Howard Owen 11 1,561 09-16-2013, 02:53 PM
Last Post: Fred Lusk
  50g piecewise functions Kurt Fankhauser 6 987 09-15-2013, 08:01 PM
Last Post: Kurt Fankhauser

Forum Jump: