HP-41: Formula Evaluation ROM
06-06-2017, 05:27 PM (This post was last modified: 06-06-2017 05:34 PM by Ángel Martin.)
Post: #1
 Ángel Martin Senior Member Posts: 1,261 Joined: Dec 2013
HP-41: Formula Evaluation ROM
Quick test, answer yes/no to the following:

1. Are you tired of de-constructing formulas to program them in your RPN calculator?
2. Do you secretly wish there was possible to type math expressions like in a Sharp calculator or (gasp!) an AOS machine?

If your answer to any or both above was "yes" you're in luck - assuming that is you own a 41CX and have the capability to burn ROM images for it - like Clonix/NoVoRAM, MLDL2k, and of course the LC board.

From the Martin-McClure MCODE headquarters (developers of the 16C Simulator) comes now the "Formula Evaluation ROM". a 4k Module that allows you to evaluate directly mathematical formulas typed in ALPHA without the need for any FOCAL programs.

A sizeable set of functions and operators are included, including the functions in the original OS plus the complete hyperbolic set. Plus a custom Formula Editor to make the entering process a breeze = including curved parenthesis and other special characters for better legibility.

And there's more: the module includes formula-aware versions of SV and IT, ready to be put to their paces to solve for equation roots and calculate numerical integrals of the function written in ALPHA - no RPN programs in RAM necessary.

Soon to a TOS / CL_Library near you, we're polishing the last touches before the official release.

Gamma testers welcome, holler if interested.

Cheers,
'AM
06-06-2017, 05:38 PM
Post: #2
 Namir Senior Member Posts: 813 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM
I agree with you Angel. When RPN programmable calculators were kings, programming expressions in RPN (and using smart tricks to save intermediate results) was THE way to go. Hardly anyone complained. But after over 35 years of programming high-level languages (Basic, Pascal, C, C++, Matlab, R, Python, Perl, PHP, Java, Javascript, and so on) where we use algebraic-like expressions that are easy to read (and easy to fix or edit), I am beginning to lose adoration with using RPN to code long and/or numerous expressions.

Ironically RPL calculators allow you to cheat and EVALuate algebraic expressions enclosed in single-quote strings. It's time to bring RPN engines to par with RPL.

So your solution is most welcome.

Namir
06-06-2017, 06:12 PM
Post: #3
 Gene Moderator Posts: 1,201 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM
How is it done Angel ?

Did you pull some things from the AEC rom or is this a new masterpiece of your own devising ? :-)
06-06-2017, 06:46 PM
Post: #4
 Ángel Martin Senior Member Posts: 1,261 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM
(06-06-2017 06:12 PM)Gene Wrote:  How is it done Angel ?

Did you pull some things from the AEC rom or is this a new masterpiece of your own devising ? :-)

Entirely new code, nothing from the AECROM which did the FOCAL self-programming, not the formula interpretation like ours do.

It's all new ideas, Greg's design of a "symbolic buffer" where the intermediate steps (values, functions and status) are pushed to and popped from as required according to the syntax. A beauty to see in action ;-)
06-06-2017, 06:53 PM
Post: #5
 Massimo Gnerucci Senior Member Posts: 2,376 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM

Greetings,
Massimo

-+×÷ ↔ left is right and right is wrong
06-06-2017, 07:16 PM (This post was last modified: 06-06-2017 07:18 PM by Luigi Vampa.)
Post: #6
 Luigi Vampa Member Posts: 258 Joined: Dec 2015
RE: HP-41: Formula Evaluation ROM
[OFF TOPIC]
Dear Ángel,
You are unbelievable boy! I wish you devoted your gifted mind to the HP42s sometime in the future :0)
At some point, you must find HP41's limits, if any ;0)

Saludos Saluti Cordialement Cumprimentos MfG BR + + + + +
Luigi Vampa +
Free42 HuaweiP10 '<3' I + + +
06-06-2017, 07:18 PM
Post: #7
 gjmcclure Junior Member Posts: 28 Joined: Jul 2014
RE: HP-41: Formula Evaluation ROM
BTW, the EVAL function also works with FINTG and FROOT from Ángel's Sandmath module as well if you are used to using these fine MCODE functions! I do like the SV and IT functions (which won't require any other module except Lib4, only they are FOCAL code, which reminds me I need to insure the full register usage is mentioned in the manual...), and there are some nice EVAL examples in the module. It is almost ready to release, and Ángel's documentation is worth reading (I love his formula entry program, it is the highlight of the module)...

Greg M
06-06-2017, 07:27 PM
Post: #8
 aurelio Senior Member Posts: 590 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM
(06-06-2017 06:53 PM)Massimo Gnerucci Wrote:

Great new Angel, very expressive your, Massimo
06-06-2017, 10:05 PM (This post was last modified: 06-06-2017 10:17 PM by pier4r.)
Post: #9
 pier4r Senior Member Posts: 2,076 Joined: Nov 2014
RE: HP-41: Formula Evaluation ROM
(06-06-2017 05:38 PM)Namir Wrote:  I agree with you Angel. When RPN programmable calculators were kings, programming expressions in RPN (and using smart tricks to save intermediate results) was THE way to go. Hardly anyone complained. But after over 35 years of programming high-level languages (Basic, Pascal, C, C++, Matlab, R, Python, Perl, PHP, Java, Javascript, and so on) where we use algebraic-like expressions that are easy to read (and easy to fix or edit), I am beginning to lose adoration with using RPN to code long and/or numerous expressions.

Ironically RPL calculators allow you to cheat and EVALuate algebraic expressions enclosed in single-quote strings. It's time to bring RPN engines to par with RPL.

So your solution is most welcome.

Namir

Maybe because I do read formulas like sentences and I do not break down in my mind (except for parentheses and co), but I never used the RPN aside from very short formulas involving maximum 5-6 operators.

Also on the free42 is the same. In the worst case I save intermediate parts and then I combine those.

Otherwise I either write it down in the source code, so it may take a bit longer but I have a comment for it, or I write the algebraic form.

Also, if the formula itself is not so "easy" in computational terms, like a summation, the overhead to convert the formula from algebraic to RPL code seems negligible, at least with the 50g.

So in short, I agree with Namir.

edit: I forgot. Kudos for the work, Angel. I saw a lot of those works for the 41 and I believe they are all very neat, unfortunately the 41 is outside my interest unless I misunderstood its capabilities (the 42s/free42 should be a superset of it, right?).

Wikis are great, Contribute :)
06-07-2017, 02:33 AM
Post: #10
 Gene Moderator Posts: 1,201 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM
So what limits ?

24 character alpha or is that removed ?

Pending operations?

How to scroll to replace a value ?
06-07-2017, 04:06 AM
Post: #11
 gjmcclure Junior Member Posts: 28 Joined: Jul 2014
RE: HP-41: Formula Evaluation ROM
(06-07-2017 02:33 AM)Gene Wrote:  So what limits ?

24 character alpha or is that removed ?

Pending operations?

How to scroll to replace a value ?

Gene,

Alpha register is used, yes 24-char limit on formula. However supported functions will be abbreviated to 1 to 3 chars (i.e S for Sine), up to 9 digit integer values allowed in functions, function precedence (^ over * / and MOD, * / MOD over + -), parenthesis used to override precedence.

For this version we did our best to allow the 24 characters to yield the most formula, there are more steps to be taken in future versions of this. One trick explained in the manual to extend the formula will be to use part of the equation, save the result in Y instead of X (and yes the result can be saved to X, Y, Z, T, or L). Then complete the equation using Y for the previous partial result.

Not sure what you mean by limits, but any calculation limits would be the same limit of the function/operation chosen (i.e. for Sine the parameter can be any value Sine accepts on the 41).

Formula replacement is just to put another formula into the Alpha. The EVAL functions will be programmable, so support for storing and recalling the formula to a set of registers is done. A formula creation function is available to make easy formulas. Some example functions will be included on the ROM in FOCAL, i.e. quadratic formula.

I am currently trying to break the release candidate version Angel last sent me, so far, so good!

Greg
06-10-2017, 08:53 AM (This post was last modified: 06-10-2017 08:56 AM by Ángel Martin.)
Post: #12
 Ángel Martin Senior Member Posts: 1,261 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM
Module and manual now posted at TOS - Check the "What's New" section.

Also available on the CL web site:
http://systemyde.com/pdf/Formula_Evaluation.pdf

Thanks to Warren Furlow and Monte Dalrymple for hosting the documents.
06-10-2017, 01:30 PM
Post: #13
 rprosperi Senior Member Posts: 5,066 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM
(06-10-2017 08:53 AM)Ángel Martin Wrote:  Module and manual now posted at TOS - Check the "What's New" section.

Also available on the CL web site:
http://systemyde.com/pdf/Formula_Evaluation.pdf

Thanks to Warren Furlow and Monte Dalrymple for hosting the documents.

Thanks to you and Greg for continuing to extend the '41 into new realms!

Any idea if Michael will be making this new overlay available? Looks like it will be helpful if not necessary to use this effectively.

--Bob Prosperi
06-10-2017, 03:01 PM
Post: #14
 Ángel Martin Senior Member Posts: 1,261 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM
(06-10-2017 01:30 PM)rprosperi Wrote:  Any idea if Michael will be making this new overlay available? Looks like it will be helpful if not necessary to use this effectively.

Actually this one is very intuitive, as for the most part (say 90% of functions) the same standard keys are used to type the function. Try iy out and you'll see what I mean.

But of course I'd love to have a new overlay, I'm assuming Michael would need a minimum order volume though.
06-10-2017, 08:34 PM
Post: #15
 JurgenRo Member Posts: 176 Joined: Jul 2015
RE: HP-41: Formula Evaluation ROM
(06-10-2017 08:53 AM)Ángel Martin Wrote:  Module and manual now posted at TOS - Check the "What's New" section.

Also available on the CL web site:
http://systemyde.com/pdf/Formula_Evaluation.pdf

Thanks to Warren Furlow and Monte Dalrymple for hosting the documents.

Awesome! Simply awesome! Thanks a lot for the new gem!!
Alte the Best,
Juergen
06-11-2017, 09:16 AM (This post was last modified: 06-12-2017 11:17 AM by Ángel Martin.)
Post: #16
 Ángel Martin Senior Member Posts: 1,261 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM
(06-10-2017 08:34 PM)JurgenRo Wrote:  Awesome! Simply awesome! Thanks a lot for the new gem!!
Alte the Best,
Juergen

Glad to see it's appreciated, a lot of work went into it!

BTW I recently added more examples in the ROM, for the most common Orthogonal polynomials. The routines won't beat the speed of the MCODE-based functions in the SandMath and SandMatrix, but show how to use EVAL$in a DSE-controlled loop. Here's the code, including Legendre LEG$, Hermite HMT$, and Chebyshev's 1st. & 2nd. kinds HNX$, UNX$- all four in 50 steps, not bad at all. Enter the order "n" in Y and the argument "x" in X, then execute the routine. The result is left in X, and the previous order result in LastX. No data registers used. Code: 1 LBL "LEG$ 2    4 3    "((2*T-1)*Z*X-L" 4    "|- (T-1))/T"   - first char is append 5    GTO 00 6    LBL "HMT$7 3 8 GTO 00 9 LBL "TNX$ 10    0 11    GTO 00 12    LBL "UNX$13 E 14 LBL 00 15 X<>F 16 RDN 17 X<>Y 18 X=0? 19 GTO 00 20 E 21 X=Y? 22 GTO 01 23 STO T 24 FS? 02 25 ST+ T 26 - 27 X<>Y 28 STO Z 29 FS? 00 30 ST+ X 31 FS? 02 32 GTO 02 33 "2*Z*X-L" 34 FS? 01 35 "|- *2*T" - first char is append 36 LBL 02 37 EVAL$ 38    ISG T 39    NOP 40    DSE Y 41    GTO 02 42    RTN 43    LBL 00 44    E 45    RTN 46    LBL 01 47    X<>Y 48    FS? 00 49    ST+ X 50    END
06-11-2017, 03:47 PM
Post: #17
 Gene Moderator Posts: 1,201 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM
Step 4: "|-(T-1))/T"

The first character is an append sign. This makes sense as step 4 would overwrite step 3 otherwise.

Thanks to Angel for the confirmation and help.
06-12-2017, 07:13 AM (This post was last modified: 06-12-2017 08:40 AM by Ángel Martin.)
Post: #18
 Ángel Martin Senior Member Posts: 1,261 Joined: Dec 2013
RE: HP-41: Formula Evaluation ROM
(06-11-2017 03:47 PM)Gene Wrote:  Step 4: "|-(T-1))/T"

The first character is an append sign. This makes sense as step 4 would overwrite step 3 otherwise.

Thanks to Angel for the confirmation and help.

And the same for line #35 - and in general for every formula that spans two program steps.

Here's another example to calculate the Lambert function W(x)

This one requires calling EVAL$twice because Newton's formula exceeds 24 chars, so we break it in two sections. Despite that it only takes 15 steps. Type: x, XEQ "WL$" => successive approximations shown until final result.
Note that in some cases there may be some oscillations around the last decimal digit due to the Newton method. You can modify the program to cover for this contingency (the root cause is the X#Y? instruction at step #13, thus you can add X<>Y, RND, X<>Y RND right before the test is made - with the calculator in FIX 9).

Code:
1    LBL "WL$2 STO Z 3 LN1+X 4 STO L 5 LBL 00 6 STO Y 7 "X*E(X)" 8 EVAL$ 9    "L-((X-Z)/(X+E(L" 10    "|- )))"  - append and 3 paren 11    EVAL$12 VIEW X 13 X#Y? 14 GTO 00 15 END 06-12-2017, 07:36 AM (This post was last modified: 06-12-2017 08:40 AM by Ángel Martin.) Post: #19  Ángel Martin Senior Member Posts: 1,261 Joined: Dec 2013 RE: HP-41: Formula Evaluation ROM Well, here's a shorter version that only requires calling EVAL$ once - I should have remember those pesky precedence rules ;-)

This version also adds the rounding to avoid the oscillations.

Code:
1    LBL "WL$2 FIX 9 3 STO Z 4 LN1+X 5 "X-(X*E(X)-Z)/(1" 6 "|- +X)/E(X)" - append 7 LBL 00 8 STO Y 9 EVAL$ 10    FS? 10 11    VIEW X 12    X<>Y 13    RND 14    X<>Y 15    RND 16    X#Y? 17    GTO 00 18    END
 « Next Oldest | Next Newest »

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