Best calculator for recurrence relations

02182020, 03:50 AM
(This post was last modified: 02202020 05:31 AM by carey.)
Post: #1




Best calculator for recurrence relations
I have begun using recurrence relations (mainly threeterm) and am wondering if anyone finds a particular calculator model's sequence/recursive mode to be more powerful than others? While not difficult to write programs to work with expressions like A(n) = A(n1) + A(n2), the convenience of a builtin feature is nice. I'm curious if anyone knows of any calculator model with a sequence/recursive mode that handles simultaneous recurrence relations or more than three terms? Thanks!


02182020, 05:21 AM
Post: #2




RE: Best calculator for sequences (recurrence relations)
HP 38G does this very well  indeed, range of N catered for is greater than in the Prime.


02182020, 01:07 PM
Post: #3




RE: Best calculator for sequences (recurrence relations)
The TI84 Plus CE will let you do A(n), A(n+1), or A(n+2), and also lets you set the starting value of n (default is 1). Not sure how other members of the 84 family compare, but they're likely similar.


02182020, 02:05 PM
Post: #4




RE: Best calculator for sequences (recurrence relations)
(02182020 05:21 AM)Gerald H Wrote: HP 38G does this very well  indeed, range of N catered for is greater than in the Prime. The Sequence app in the Prime has a very nice interface, too bad it is limited to 12digit approximate numbers. If it could be updated to use exact integers, it would be truly useful. 

02182020, 08:29 PM
Post: #5




RE: Best calculator for sequences (recurrence relations)
Prime will only accept N up to 32767, thereafter declares NaN.


02182020, 09:30 PM
Post: #6




RE: Best calculator for sequences (recurrence relations)
The 50g (and other RPLs?) have the SEQ command.


02182020, 10:08 PM
Post: #7




RE: Best calculator for sequences (recurrence relations)  
02192020, 06:12 PM
Post: #8




RE: Best calculator for sequences (recurrence relations)
(02182020 09:30 PM)David Hayden Wrote: The 50g (and other RPLs?) have the SEQ command. The SEQ command (HP48g and later) is just a "user friendly" FOR..STEP loop, and cannot do recursive sequences. Recursive sequences can only be done by programming, which can be difficult for complex sequences such as Hofstadter Qsequences. 

02232020, 10:54 AM
Post: #9




RE: Best calculator for recurrence relations
The programme below will return the Nth Fibonacci number for natural number N input:
Code: « 0 1 

02232020, 07:09 PM
Post: #10




RE: Best calculator for recurrence relations
Neat, but can you do this with SEQ?


02252020, 03:08 PM
(This post was last modified: 02252020 03:10 PM by Csaba Tizedes.)
Post: #11




RE: Best calculator for recurrence relations
(02232020 07:09 PM)John Keith Wrote: Neat, but can you do this with SEQ? I don't know how it is works on HPs, but on TI83 you can do something like this: first decide the max. index of your list: N then generate the list, let's say Z: seq(1,X,1,N,1)>LZ finally generate the sequence: augment({1,1},seq(LZ(LZ(X2))+LZ(XLZ(X2)),X,3,N,1))>LZ and press ENTER until the result list is not change. Just an idea, must to check, but I'm sure it is works. There are models where sequences are implemented, maybe you can do it on those models (HP38/39 models, some CASIO models), but I am not sure the result is a list, maybe a table in an application. Csaba 

02252020, 04:14 PM
Post: #12




RE: Best calculator for recurrence relations
(02252020 03:08 PM)Csaba Tizedes Wrote: I don't know how it is works on HPs, but on TI83 you can do something like this: Should work, though it'll be fairly slow for large lists, since you'll have to run it about as many times as you have list elements. Here's a little 84 Plus CE program that prompts for all the inputs. This uses toString() to show the subscript when prompting for constants; this would have to be changed for an 83 (probably Disp X followed by an Input). Also, some of the prompt messages would need to be wrapped to fit the monochrome LCD models. Code: Input "NUMBER OF CONSTANTS? ",C The terms are calculated one at a time in increasing subscript order, and the list dimension increases by one with each term appended. Forward references will fail with a dimension error, i.e. you can only refer to prior (already calculated) list elements. You can rcl Y1 at the expression entry prompt if you want to run the program again with the same recursive formula, but different constants or max N. I tested it with the example  L1(1)=L1(2)=1, L1(N)=L1(L1(N2))+L1(NL1(N2))  and got the same first 20 terms. 

02252020, 07:15 PM
Post: #13




RE: Best calculator for recurrence relations
(02232020 07:09 PM)John Keith Wrote: Neat, but can you do this with SEQ? Well, it won't win any awards for speed, but the subscripting allowed in symbolic expressions on the 50g does allow a fairly straightforward way to do this. It's not recursive, of course, but this does seem to work for the samples I've tested: Code: \<< Notes: 1) There's no error checking of the input argument (the maximum "n", which must be >2) 2) SEQ wants to build a final list from the results of each iteration of the executable, but in this case the result is simply appended to the existing array for future computations. There's nothing new on the stack for SEQ to encapsulate when it completes, and the stackbased result is not included since it was created before SEQ executes. It's not particularly elegant, but it works. This could probably be sped up by doing the computations on the stack instead of with a symbolic expression, but the readability would take a significant hit (IMHO). 

02252020, 08:01 PM
Post: #14




RE: Best calculator for recurrence relations
(02252020 07:15 PM)DavidM Wrote: This could probably be sped up by doing the computations on the stack instead of with a symbolic expression, but the readability would take a significant hit (IMHO). This is indeed the case. You end up with lots of PICKs and GETs and the programs are as hard to write as they are to read. They are also a lot faster. For example, here is a program for a similar sequence: Code:


02262020, 03:28 PM
Post: #15




RE: Best calculator for recurrence relations
This program seemed like a good example of where precompiling the executable passed to SEQ would help, so I decided to try a version that did that:
Code: \<< "Precompiling" the symbolic expression is done with the →PRG command (on page 3 of the builtin Development Library menu [#256]). There's a subtlety here that needs to be noted: the variables in the symbolic will be compiled as either globals or locals depending on the context of where they are used in the program. That's why I went ahead and preallocated the locals in this version  this ensures that the compiled program will correctly use locals as opposed to globals when it is executed by SEQ. This issue can be explicitly dealt with by using "precompiled locals", but I believe that syntax gets more messy than it's worth in situations like this. Precompiling the executable makes this version about 59% faster on my 50g. There was also a redundant R→I in the original version which was removed. That impact was negligible, though. 

02262020, 07:56 PM
Post: #16




RE: Best calculator for recurrence relations
That is really cool! I never realized that you could do that with SEQ. While it is a lot slower than the stackbased version, your program allows one to type (or paste) in a formula directly and see the result. Additionally there is the advantage of exact integers so no restrictions like the Prime Sequence app.
I have learned a lot from you and Gerald here, as is often the case. 

« Next Oldest  Next Newest »

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