Post Reply 
HP 38G: Better than Prime for some Sequences using the built in Sequence App
03-06-2015, 07:46 AM (This post was last modified: 03-07-2015 12:28 PM by Gerald H.)
Post: #1
HP 38G: Better than Prime for some Sequences using the built in Sequence App
Edited 2015-03-07: Removed question mark from title of thread

I post here a challenge:

For

http://oeis.org/search?q=a004001&languag...&go=Search

This works on the 38G:

U1(1)=1
U1(2)=1
U1(N)=U1(U1(N-1))+U1(N-U1(N-1)).

On the Prime & 39gii it refuses to get ticked & is consequently unevaluable.

Should I however be in error I would be very pleased to see a demonstration of how to realize the series on either Prime or 39gii.


I offer a prize of an HP 38G to the first successful solution posted here in this forum.
Find all posts by this user
Quote this message in a reply
03-06-2015, 07:49 AM
Post: #2
RE: HP 38G: Better than Prime for Sequences?
(03-06-2015 07:46 AM)Gerald H Wrote:  I offer a prize of an HP 38G to the first successful solution posted here in this forum.

If that is the prize I doubt you'll find many takers... ;)

SCNR

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
03-06-2015, 07:55 AM
Post: #3
RE: HP 38G: Better than Prime for Sequences?
(03-06-2015 07:49 AM)Massimo Gnerucci Wrote:  
(03-06-2015 07:46 AM)Gerald H Wrote:  I offer a prize of an HP 38G to the first successful solution posted here in this forum.

If that is the prize I doubt you'll find many takers... Wink

SCNR

Oh, I don't know - If the poor old useless calculator can solve something the Prime can't?
Find all posts by this user
Quote this message in a reply
03-07-2015, 01:41 AM
Post: #4
RE: HP 38G: Better than Prime for Sequences?
(03-06-2015 07:46 AM)Gerald H Wrote:  This works on the 38G:

U1(1)=1
U1(2)=1
U1(N)=U1(U1(N-1))+U1(N-U1(N-1)).

On the Prime & 39gii it refuses to get ticked & is consequently unevaluable.

Fascinating. The 40gs handles it fine too. I wonder why the 39gii and Prime balk at it.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
03-07-2015, 05:29 AM (This post was last modified: 03-07-2015 05:31 AM by BruceH.)
Post: #5
RE: HP 38G: Better than Prime for Sequences?
(03-07-2015 01:41 AM)Joe Horn Wrote:  Fascinating. The 40gs handles it fine too. I wonder why the 39gii and Prime balk at it.
It's to do with the use of U1 as the index to U1. I tried setting U2 to be U1(N-1) and making the appropriate substitution and that still fails. Creating a user defined function TT(N)=U1(N-1) and substituting also fails. So I think the Sequence app is scanning the parse tree in an effort to avoid a recursive loop and is rejecting cases that would actually work.
Find all posts by this user
Quote this message in a reply
03-07-2015, 06:02 AM
Post: #6
RE: HP 38G: Better than Prime for Sequences?
(03-07-2015 05:29 AM)BruceH Wrote:  
(03-07-2015 01:41 AM)Joe Horn Wrote:  Fascinating. The 40gs handles it fine too. I wonder why the 39gii and Prime balk at it.
It's to do with the use of U1 as the index to U1. I tried setting U2 to be U1(N-1) and making the appropriate substitution and that still fails. Creating a user defined function TT(N)=U1(N-1) and substituting also fails. So I think the Sequence app is scanning the parse tree in an effort to avoid a recursive loop and is rejecting cases that would actually work.

Yes indeed, there's more than one way to skin a cat.

It's a poor comment on the makers of the calculator that it acts like that & it's a poor comment on the Prime adepts that they can't find a way to obviate the problem.
Find all posts by this user
Quote this message in a reply
03-07-2015, 07:40 AM (This post was last modified: 03-07-2015 09:57 AM by BruceH.)
Post: #7
RE: HP 38G: Better than Prime for Sequences?
(03-07-2015 06:02 AM)Gerald H Wrote:  ... & it's a poor comment on the Prime adepts that they can't find a way to obviate the problem.
No good deed goes unpunished, as they say.

By way of revenge I offer you this:
Code:
EXPORT TT(n)
BEGIN
  IF N<=2 THEN
    RETURN(1);
  ELSE
    RETURN(TT(TT(n-1))*TT(n-TT(n-1)); //typo: should be + not * - thanks to Thomas below
  END;
END;
and set
Code:
U1(1)=1
U1(2)=1
U1(N)=TT(N)
in the Sequence symbolic view.

Could you check the value for U1(99) for me please? ;-)
Find all posts by this user
Quote this message in a reply
03-07-2015, 08:21 AM
Post: #8
RE: HP 38G: Better than Prime for Sequences?
(03-07-2015 07:40 AM)BruceH Wrote:  
(03-07-2015 06:02 AM)Gerald H Wrote:  ... & it's a poor comment on the Prime adepts that they can't find a way to obviate the problem.
No good deed goes unpunished, as they say.

By way of revenge I offer you this:
Code:
EXPORT TT(n)
BEGIN
  IF N<=2 THEN
    RETURN(1);
  ELSE
    RETURN(TT(TT(n-1))*TT(n-TT(n-1));
  END;
END;
and set
Code:
U1(1)=1
U1(2)=1
U1(N)=TT(N)
in the Sequence symbolic view.

Could you check the value for U1(99) for me please? ;-)

Entering your prog TT exactly as depicted above & running Sequence App 99 gives the value 1, incorrect.

& for all vlues the App returns 1.
Find all posts by this user
Quote this message in a reply
03-07-2015, 08:25 AM (This post was last modified: 03-07-2015 08:27 AM by Tugdual.)
Post: #9
RE: HP 38G: Better than Prime for Sequences?
Can you do that on a 48G? I mean without specific programming...
Find all posts by this user
Quote this message in a reply
03-07-2015, 08:27 AM
Post: #10
RE: HP 38G: Better than Prime for Sequences?
(03-07-2015 08:25 AM)Tugdual Wrote:  Can you do that on a 48G?

Can you do better than that on a Cray supercomputer?
Find all posts by this user
Quote this message in a reply
03-07-2015, 08:33 AM (This post was last modified: 03-07-2015 08:33 AM by Gerald H.)
Post: #11
RE: HP 38G: Better than Prime for Sequences?
And so the traditional 24 hr competition deadline is overrun & I withdraw the prize for a correct solution.

Massimo thinks the prize made no difference anyway.

Should anyone find a method of dealing with this annoyance I'd still be glad to learn of it.

Thank you for your comments to the thread.
Find all posts by this user
Quote this message in a reply
03-07-2015, 08:34 AM (This post was last modified: 03-07-2015 08:36 AM by Thomas Ritschel.)
Post: #12
RE: HP 38G: Better than Prime for Sequences?
(03-07-2015 08:21 AM)Gerald H Wrote:  
(03-07-2015 07:40 AM)BruceH Wrote:  No good deed goes unpunished, as they say.

By way of revenge I offer you this:
Code:
EXPORT TT(n)
BEGIN
  IF N<=2 THEN
    RETURN(1);
  ELSE
    RETURN(TT(TT(n-1))*TT(n-TT(n-1));
  END;
END;
and set
Code:
U1(1)=1
U1(2)=1
U1(N)=TT(N)
in the Sequence symbolic view.

Could you check the value for U1(99) for me please? ;-)

Entering your prog TT exactly as depicted above & running Sequence App 99 gives the value 1, incorrect.

& for all vlues the App returns 1.

There is a typo in the equation. It should read:
Code:
    RETURN(TT(TT(n-1))+TT(n-TT(n-1)));
Note the "+" sign...

For N=99 it should return 56. But on the 39gII it takes ages! Actually it hasn't finished yet (after 10 minutes or so...).
Find all posts by this user
Quote this message in a reply
03-07-2015, 08:45 AM
Post: #13
RE: HP 38G: Better than Prime for Sequences?
(03-07-2015 08:34 AM)Thomas Ritschel Wrote:  
(03-07-2015 08:21 AM)Gerald H Wrote:  Entering your prog TT exactly as depicted above & running Sequence App 99 gives the value 1, incorrect.

& for all vlues the App returns 1.

There is a typo in the equation. It should read:
Code:
    RETURN(TT(TT(n-1))+TT(n-TT(n-1)));
Note the "+" sign...

For N=99 it should return 56. But on the 39gII it takes ages! Actually it hasn't finished yet (after 10 minutes or so...).

No, I still get a long list of 1s.
Find all posts by this user
Quote this message in a reply
03-07-2015, 10:07 AM (This post was last modified: 03-07-2015 10:17 AM by Thomas Ritschel.)
Post: #14
RE: HP 38G: Better than Prime for Sequences?
(03-07-2015 08:45 AM)Gerald H Wrote:  No, I still get a long list of 1s.

I had the same problem. Somehow the 39gII doesn't recognize that a program has been changed.
One has to edit the formula in the sequence app once again (or maybe twice) to get it working.

Anyway, even in HOME view on the 39gII it already takes about 20 seconds to compute TT(15). For larger arguments it doesn't finish in reasonable time...

Edit: For TT(20) it takes about 11 minutes!
Find all posts by this user
Quote this message in a reply
03-07-2015, 10:18 AM (This post was last modified: 03-07-2015 10:22 AM by Gerald H.)
Post: #15
RE: HP 38G: Better than Prime for Sequences?
(03-07-2015 08:25 AM)Tugdual Wrote:  Can you do that on a 48G? I mean without specific programming...

I refer you to this thread:

http://www.hpmuseum.org/forum/thread-3292.html
Find all posts by this user
Quote this message in a reply
03-07-2015, 10:20 AM
Post: #16
RE: HP 38G: Better than Prime for Sequences?
(03-07-2015 10:07 AM)Thomas Ritschel Wrote:  
(03-07-2015 08:45 AM)Gerald H Wrote:  No, I still get a long list of 1s.

I had the same problem. Somehow the 39gII doesn't recognize that a program has been changed.
One has to edit the formula in the sequence app once again (or maybe twice) to get it working.

Anyway, even in HOME view on the 39gII it already takes about 20 seconds to compute TT(15). For larger arguments it doesn't finish in reasonable time...

Edit: For TT(20) it takes about 11 minutes!

I'm using that glorious instrument, the Prime, & not that obsolete **** of ****** that no one could want & wouldn't **** to a ******** for any *****.
Find all posts by this user
Quote this message in a reply
03-07-2015, 10:28 AM (This post was last modified: 03-07-2015 10:30 AM by Thomas Ritschel.)
Post: #17
RE: HP 38G: Better than Prime for Sequences?
(03-07-2015 10:07 AM)Thomas Ritschel Wrote:  Anyway, even in HOME view on the 39gII it already takes about 20 seconds to compute TT(15). For larger arguments it doesn't finish in reasonable time...

Edit: For TT(20) it takes about 11 minutes!

There is a significant speed-up if one changes the ELSE case into:
Code:
    LOCAL TT1:=TT(n-1);
    RETURN(TT(TT1)+TT(n-TT1));

Now one gets TT(20) almost immediately and TT(40) in just 7 seconds...
Find all posts by this user
Quote this message in a reply
03-07-2015, 10:41 AM
Post: #18
RE: HP 38G: Better than Prime for Sequences
(03-07-2015 10:28 AM)Thomas Ritschel Wrote:  
(03-07-2015 10:07 AM)Thomas Ritschel Wrote:  Anyway, even in HOME view on the 39gII it already takes about 20 seconds to compute TT(15). For larger arguments it doesn't finish in reasonable time...

Edit: For TT(20) it takes about 11 minutes!

There is a significant speed-up if one changes the ELSE case into:
Code:
    LOCAL TT1:=TT(n-1);
    RETURN(TT(TT1)+TT(n-TT1));

Now one gets TT(20) almost immediately and TT(40) in just 7 seconds...

Still won't work on Prime.
Find all posts by this user
Quote this message in a reply
03-07-2015, 10:46 AM
Post: #19
RE: HP 38G: Better than Prime for Sequences
(03-07-2015 10:41 AM)Gerald H Wrote:  Still won't work on Prime.

Make sure that you changed the line
Code:
IF N<=2 THEN
into
Code:
IF n<=2 THEN

Otherwise the Prime may recognize N and n as different variables...
Find all posts by this user
Quote this message in a reply
03-07-2015, 10:53 AM
Post: #20
RE: HP 38G: Better than Prime for Sequences
(03-07-2015 10:46 AM)Thomas Ritschel Wrote:  
(03-07-2015 10:41 AM)Gerald H Wrote:  Still won't work on Prime.

Make sure that you changed the line
Code:
IF N<=2 THEN
into
Code:
IF n<=2 THEN

Otherwise the Prime may recognize N and n as different variables...

I entered the prog exactly as above, respecting capitalization.

I have read elsewhere on the forum that capitals or uncials can make all the difference. I shall try.
Find all posts by this user
Quote this message in a reply
Post Reply 




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