41Z Routine of the Week: Complex Fibonacci - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP-41C Software Library (/forum-11.html) +--- Thread: 41Z Routine of the Week: Complex Fibonacci (/thread-15366.html) |
41Z Routine of the Week: Complex Fibonacci - Ángel Martin - 07-23-2020 11:32 AM Complex Fibonacci Numbers The routine below uses the Binet formula with real orders "x" to obtain the Complex Fibonacci numbers. For integer inputs you should get the known Fibonacci series, but it gets interesting when you use non-integer values for the input. This link shows graphs of the function output values in a couple of cases. Input: x in the X register. The program listing is below, step #4 PHI is the golden ratio, ~1.6108339887... Code: 01 LBL "ZFIB" RE: 41Z Routine of the Week: Complex Fibonacci - JMBaillard - 07-23-2020 08:00 PM Hi Angel, Thank you for your program. Here is a focal version for complex arguments: 01 LBL "FIBZ" 02 STO 01 03 X<>Y 04 STO 02 05 CHS 06 PI 07 ST* Z 08 * 09 RCL Y 10 RCL Y 11 E^X 12 RAD 13 P-R 14 R^ 15 CHS 16 R^ 17 CHS 18 E^X 19 P-R 20 X<>Y 21 ST+ T 22 RDN 23 + 24 2 25 ST/ Z 26 / 27 R-P 28 STO 03 29 X<>Y 30 STO 04 31 5 32 SQRT 33 1 34 + 35 2 36 / 37 STO 00 38 LN 39 RCL 02 40 * 41 ST- 04 42 RCL 00 43 RCL 01 44 Y^X 45 ST/ 03 46 P-R 47 RCL 04 48 RCL 03 49 P-R 50 X<>Y 51 ST- T 52 RDN 53 - 54 5 55 SQRT 56 ST/ Z 57 / 58 DEG 59 END ( 77 bytes / SIZE 005 ) Y=y >>> Y'=v X=x >>> X'=u with Fib(x+i.y) = u+i.v Example: .4 ENTER^ .3 XEQ "FIBZ" >>>> 0.179726826 ( 5 seconds ) X<>Y 0.677764999 Fib(0.3+0.4 i) ~ 0.179726826 + 0.677764999 i Best regards. RE: 41Z Routine of the Week: Complex Fibonacci - Ángel Martin - 07-25-2020 09:11 AM Very nice JM, thanks for your contribution. here's the 41Z version to use for complex orders - which requires a modified Binet formula using an interesting correction term: input is the complex order z in {Y, X} 41 bytes / SIZE 000 Code: 01 LBL "ZFIB" Example: Fi(3+4i) ~ -5,248.511-J14,195.962 Cheers, ÁM |