HP Forums
HP 38G: Better than Prime for some Sequences using the built in Sequence App - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP 38G: Better than Prime for some Sequences using the built in Sequence App (/thread-3278.html)

Pages: 1 2 3


HP 38G: Better than Prime for some Sequences using the built in Sequence App - Gerald H - 03-06-2015 07:46 AM

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.


RE: HP 38G: Better than Prime for Sequences? - Massimo Gnerucci - 03-06-2015 07:49 AM

(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


RE: HP 38G: Better than Prime for Sequences? - Gerald H - 03-06-2015 07:55 AM

(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?


RE: HP 38G: Better than Prime for Sequences? - Joe Horn - 03-07-2015 01:41 AM

(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.


RE: HP 38G: Better than Prime for Sequences? - BruceH - 03-07-2015 05:29 AM

(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.


RE: HP 38G: Better than Prime for Sequences? - Gerald H - 03-07-2015 06:02 AM

(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.


RE: HP 38G: Better than Prime for Sequences? - BruceH - 03-07-2015 07:40 AM

(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? ;-)


RE: HP 38G: Better than Prime for Sequences? - Gerald H - 03-07-2015 08:21 AM

(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.


RE: HP 38G: Better than Prime for Sequences? - Tugdual - 03-07-2015 08:25 AM

Can you do that on a 48G? I mean without specific programming...


RE: HP 38G: Better than Prime for Sequences? - Gerald H - 03-07-2015 08:27 AM

(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?


RE: HP 38G: Better than Prime for Sequences? - Gerald H - 03-07-2015 08:33 AM

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.


RE: HP 38G: Better than Prime for Sequences? - Thomas Ritschel - 03-07-2015 08:34 AM

(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...).


RE: HP 38G: Better than Prime for Sequences? - Gerald H - 03-07-2015 08:45 AM

(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.


RE: HP 38G: Better than Prime for Sequences? - Thomas Ritschel - 03-07-2015 10:07 AM

(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!


RE: HP 38G: Better than Prime for Sequences? - Gerald H - 03-07-2015 10:18 AM

(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


RE: HP 38G: Better than Prime for Sequences? - Gerald H - 03-07-2015 10:20 AM

(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 *****.


RE: HP 38G: Better than Prime for Sequences? - Thomas Ritschel - 03-07-2015 10:28 AM

(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...


RE: HP 38G: Better than Prime for Sequences - Gerald H - 03-07-2015 10:41 AM

(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.


RE: HP 38G: Better than Prime for Sequences - Thomas Ritschel - 03-07-2015 10:46 AM

(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...


RE: HP 38G: Better than Prime for Sequences - Gerald H - 03-07-2015 10:53 AM

(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.