[VA] SRC#003- New Year 2019 Special
01-17-2019, 06:04 PM
Post: #7
 DavidM Senior Member Posts: 853 Joined: Dec 2013
RE: [VA] SRC#003- New Year 2019 Special
Not being well-versed in the mathematics behind this, my attempt was simply a naïve/brute force loop to compare successive results until the first duplicate was encountered (50g/RPL):
Code:
 \<<    [['\pi' 2019. 2019.][1. '\pi' 2019.][1. 1. '\pi']] \->NUM    DUP    0.    DO       UNROT       OVER *       DUP 3. GET       OVER 6. GET       /       4. ROLL    UNTIL       OVER SAME    END    NIP NIP \>>
Result: 12.6389823194
Execution time: about 12s on a real 50g.
Size: 146.5 bytes, of which 84 bytes is spent building the initial matrix. If I take that part out and require the initial matrix being left on the stack as an argument, the size drops to 62.5 bytes.

A similar approach using Thomas' first optimization:
Code:
 \<<    [['\pi' 2019. 2019.][1. '\pi' 2019.][1. 1. '\pi']] \->NUM    0. DUP 1. \->V3    0.    DO       UNROT       OVER SWAP *       DUP OBJ\-> DROP2       /       4. ROLL    UNTIL       OVER SAME    END    NIP NIP \>>
Result: 12.6389823194
Execution time: about 8.5s on a real 50g
Size: 149 bytes (with embedded matrix build), 65 bytes (initial matrix as argument)

All of which pales in comparison, of course, to Thomas' ultimate eigenvalue solution. If I assume the initial matrix is on the stack as an argument, the following code gives the result in the same format as the other routines (I optimized the retrieval of the needed matrix element as well as adding "RE" to standardize the result):
Code:
\<<    EGV DROP 4. GET INV RE \>>
Result: 12.6389823194
Execution time: about 3.8s on a real 50g
Size: 28 bytes

Great job Thomas! (as usual). And thanks to Valentin for an interesting problem -- I hope to see more about the underlying concepts. I think this is the first time I've actually encountered eigenvalues being used outside of a Linear Algebra course many moons ago. I've forgotten most everything I was supposed to have learned in that class, I'm afraid.
 « Next Oldest | Next Newest »

 Messages In This Thread [VA] SRC#003- New Year 2019 Special - Valentin Albillo - 01-15-2019, 10:42 PM RE: [VA] SRC#003- New Year 2019 Special - Paul Dale - 01-16-2019, 03:51 AM RE: [VA] SRC#003- New Year 2019 Special - Carsen - 01-16-2019, 03:57 AM RE: [VA] SRC#003- New Year 2019 Special - Thomas Okken - 01-16-2019, 04:24 AM RE: [VA] SRC#003- New Year 2019 Special - Thomas Klemm - 01-16-2019, 09:33 AM RE: [VA] SRC#003- New Year 2019 Special - Thomas Klemm - 01-16-2019, 09:50 AM RE: [VA] SRC#003- New Year 2019 Special - DavidM - 01-17-2019 06:04 PM RE: [VA] SRC#003- New Year 2019 Special - Thomas Klemm - 01-18-2019, 05:04 AM RE: [VA] SRC#003- New Year 2019 Special - DavidM - 01-18-2019, 07:15 PM RE: [VA] SRC#003- New Year 2019 Special - Thomas Klemm - 01-18-2019, 05:44 PM RE: [VA] SRC#003- New Year 2019 Special - Thomas Klemm - 01-18-2019, 08:28 PM RE: [VA] SRC#003- New Year 2019 Special - Thomas Klemm - 01-20-2019, 11:33 AM RE: [VA] SRC#003- New Year 2019 Special - Thomas Klemm - 01-20-2019, 06:13 PM RE: [VA] SRC#003- New Year 2019 Special - Valentin Albillo - 01-20-2019, 07:40 PM RE: [VA] SRC#003- New Year 2019 Special - Albert Chan - 02-09-2019, 01:55 AM RE: [VA] SRC#003- New Year 2019 Special - Albert Chan - 01-20-2019, 09:28 PM RE: [VA] SRC#003- New Year 2019 Special - Valentin Albillo - 01-27-2019, 09:38 PM RE: [VA] SRC#003- New Year 2019 Special - pier4r - 01-28-2019, 11:56 AM RE: [VA] SRC#003- New Year 2019 Special - Albert Chan - 01-28-2019, 12:46 PM RE: [VA] SRC#003- New Year 2019 Special - pier4r - 01-28-2019, 07:34 PM RE: [VA] SRC#003- New Year 2019 Special - Thomas Klemm - 01-28-2019, 05:40 PM RE: [VA] SRC#003- New Year 2019 Special - Thomas Klemm - 01-28-2019, 06:17 PM RE: [VA] SRC#003- New Year 2019 Special - rprosperi - 01-28-2019, 11:43 PM RE: [VA] SRC#003- New Year 2019 Special - Thomas Klemm - 01-28-2019, 11:59 PM RE: [VA] SRC#003- New Year 2019 Special - rprosperi - 01-29-2019, 02:04 AM RE: [VA] SRC#003- New Year 2019 Special - Albert Chan - 02-08-2019, 06:46 PM RE: [VA] SRC#003- New Year 2019 Special - Albert Chan - 02-08-2019, 09:36 PM

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