Computer Old Farts Forum
 help / color / mirror / Atom feed
From: dave at horsfall.org (Dave Horsfall)
Subject: [COFF] [TUHS] The most surprising Unix programs
Date: Sat, 21 Mar 2020 14:53:02 +1100 (EST)	[thread overview]
Message-ID: <alpine.BSF.2.21.9999.2003211401080.11999@aneurin.horsfall.org> (raw)
In-Reply-To: <f47a30b8-884a-843b-d820-d9d4da21ba3d@tnetconsulting.net>

On Fri, 20 Mar 2020, Grant Taylor via COFF wrote:

> However, I have to stop and think about how to enter this on an RPN 
> calculator.  I'll take a swing at this, but I might get it wrong, and I 
> don't have anything handy to test at the moment.
>
> [a] [enter]
> [a] [enter]
> [multiply]
> [b] [enter]
> [b] [enter]
> [multiply]
> [add]
> [square root]   # to solve for c

[a] [square] [enter] [b] [square] [+] [sqrt] (You don't need those extra 
"enter" keys, as the display is implicitly the top of the stack.)

> (12 keys)

7.  Well, "square" also needs the orange "shift" key, so that's really 9, 
but the number of keystrokes ain't exactly the point; it's not a race, but 
a method of thinking.

> Conversely infix notation for comparison.
>
> [a]
> [square]
> [plus]
> [b]
> [square]
> [square root]
>
> (6 keys)

[...]

Well, it really comes down to the calculation that you are trying to 
perform.  Trivial example:

1 + 1 = -> 4 keys.
1 enter 1 add -> 4 keys.

I don't have an algebraic calculator right to hand, but I'd imagine that 
solving a second-order polynomial (without a built-in program!) would 
involve fewer keys when using RPN because of the stack for intermediate 
results; a quick estimate is around 30 keys (with single-digit numbers) to 
get one of the roots, and you could probably save the result of most of it 
on the stack for re-use to get the other root (and the 42S groks complex 
numbers as a bonus[*], but that's hardly as a result of RPN).  The 42S 
also has a handy "swap x/y" if the operands are the wrong way around, 
another one to rotate the stack, etc.

You don't do Computer Science without being exposed to RPN, and I had to 
wait for a salary-in-lieu payout (long story) before I could afford the 
42S that I'd been drooling over (and forget the overpriced IR printer[#]).

[*]
1 +/- SQRT => "0.00 i1.00" (I have the display precision set to 2 because 
I use it for monetary stuff a lot; the internal precision is 15 digits).

[#]
A dream of mine is to reverse-engineer the printer protocol, then grab it 
using a laptop camera.

Here endeth today's HP-42S lesson...

-- Dave


  parent reply	other threads:[~2020-03-21  3:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200320140308.4FBBB18C073@mercury.lcs.mit.edu>
2020-03-20 16:07 ` gtaylor
2020-03-20 20:33   ` mike.ab3ap
2020-03-21  3:53   ` dave [this message]
2020-03-21  4:11     ` paul
     [not found] <202003132331.02DNVaxN061501@tahoe.cs.Dartmouth.EDU>
     [not found] ` <7ec47fd97b1a3d383ffed428f21f5287@firemail.cc>
     [not found]   ` <CALMnNGjuQybT8_g_g498dOuV9OV67JEOn7Mz34vG1TeO9WrkYw@mail.gmail.com>
     [not found]     ` <cdef128a21d3ed60c79dc5253d761652@firemail.cc>
     [not found]       ` <20200317145723.GF26660@mcvoy.com>
2020-03-17 15:41         ` clemc
2020-03-17 22:48           ` dave
     [not found]   ` <alpine.BSF.2.21.9999.2003180908300.10777@aneurin.horsfall.org>
     [not found]     ` <c44be69f-846d-55f2-2709-8765f7f5fcc4@gmail.com>
2020-03-19 21:31       ` dave
2020-03-19 21:30         ` cym224
2020-03-19 21:48           ` stewart
2020-03-21  2:49           ` dave
2020-03-21  2:55             ` lm
     [not found]         ` <6D9CA6C2-BDF2-4BCA-9503-0F8415C594C9@guertin.net>
2020-03-20 15:40           ` gtaylor
     [not found]             ` <202003201640.02KGerlG470796@darkstar.fourwinds.com>
     [not found]               ` <0b0d0ba3-7eae-a844-cc9a-ae542edb302b@tnetconsulting.net>
2020-03-20 19:11                 ` clemc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.BSF.2.21.9999.2003211401080.11999@aneurin.horsfall.org \
    --to=coff@minnie.tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).