Post Reply 
HP-41 Challenge: Double Integrals by INTEG Recursion
06-02-2016, 08:59 AM
Post: #14
RE: HP-41 Challenge: Double Integrals by INTEG Recursion
(06-01-2016 06:51 PM)Valentin Albillo Wrote:  For the record, this is the HP-71B code to compute the quintuple integral using a Monte-Carlo approach, a straightforward 3-line affair with no Math ROM needed.

>LIST

10 DESTROY ALL @ RANDOMIZE 1 @ B=.7*.8*.9*1.1 @ FOR K=1 TO 4 @ N=10^K
20 S=0 @ FOR I=1 TO N @ X=RND*.7 @ Y=RND*.8 @ Z=RND*.9 @ U=RND @ W=RND*1.1
30 S=S+SQR(6-X*X-Y*Y-Z*Z-U*U-W*W) @ NEXT I @ DISP N,S*B/N @ NEXT K

>RUN

10 1.17631976176
100 1.19138525241
1000 1.18851295632
10000 1.18896583878


The output are the results for 10, 100, 1000 and 10000 random samples, the last having 5 correct digits (save one ulp) and about as fast as the INTEGRAL approach.

Best regards.
V.

Clear and elegant; sometimes I wonder why I bother with RPN and FOCAL - so cumbersome in comparison...

Cheers,
ÁM

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP-41 Challenge: Double Integrals by INTEG Recursion - Ángel Martin - 06-02-2016 08:59 AM



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