Post Reply 
HP-42S (Free42, DM-42) mini-challenge – Wallis Product
07-05-2020, 11:20 PM (This post was last modified: 07-05-2020 11:22 PM by Valentin Albillo.)
Post: #12
RE: HP-42S (Free42, DM-42) mini-challenge – Wallis Product
.
Hi, Werner:

(07-05-2020 03:52 AM)Werner Wrote:  I came up with the same formula, Valentin. It can be simplified a lot:

00 { 27-Byte Prgm }
01▸LBL "WP"
02 ENTER
03 STO+ ST Y
04 COMB
[...]

Blame it on the 4 am ;-)

Hehe, I certainly could, I was more or less a zombie at those wee hours but I actually did notice the COMB possibility.

However I preferred to use N! instead because I thought that it added some extra value to the computation, thinking that N! behaved just like X! does in many HP models, i.e., if the argument is integer it would provide the factorial as expected, but if x wasn't integer it would return the equivalent Gamma function.

Alas, in the morning I checked it and no, in the HP42S N! doesn't work for noninteger arguments, so you have to code the equivalent Gamma evaluation in its place, which for my code above merely consist in putting the two steps "1 +" before each of the two factorials and changing both factorials to GAMMA, regardless of further optimizations (which surely are possible).

After both insertions my code runs fine and now allows for these interesting possibilites:

a) What's the value of the Wallis Product if adding up 10.5 terms ?

            10.5 XEQ "WP" -> 3.07102204549

b) What's the value of the Wallis Product if adding up Pi terms ?

            PI XEQ "WP" -> 2.93377409474

c) How many terms do we need to add up to get 3 ?

            4.9132932375 (terms) XEQ "WP" -> 3

Best regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP-42S (Free42, DM-42) mini-challenge – Wallis Product - Valentin Albillo - 07-05-2020 11:20 PM



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