HP Forums
Probable bug - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Probable bug (/thread-5544.html)



Probable bug - jefierro - 01-18-2016 01:56 PM

I was trying to find the Fibonacci sequence on the sequence app although I think this formula is not correctly stated, it shouldn't hang the machine.

I have tried this in a hardware A and the iOS version with similar results.


RE: Probable bug - cyrille de brébisson - 01-19-2016 06:03 AM

Hello,

in the app sequence symbolic view, enter:
U1(1)=1
U1(2)=2
U1(N)=U1(N-1)+U1(N-2)
Press PLOT to see the graphic.
Press Num to see the table.

Cyrille


RE: Probable bug - jefierro - 01-19-2016 06:14 AM

Thank you, that worked, but I just realize the attachment didn't upload from my phone in my original post.
I tried the following formula on the seccuance app In the latest firmware it hangs the calculator.

U1(1)=1
U1(2)=1
U1(n)=U1((n-2)+(n-1))


RE: Probable bug - primer - 01-19-2016 12:52 PM

Hi,
The problem is your formula.
(01-19-2016 06:14 AM)jefierro Wrote:  U1(1)=1
U1(2)=1
U1(n)=U1((n-2)+(n-1))
so your U1(3)=U1((3-2)+(3-1))=U1(1+2)=U1(3)
how do you want the calc to know how to deals with that ?
Regards,


RE: Probable bug - jefierro - 01-19-2016 02:02 PM

As a seasoned math geek I would rather have the thing beep at me when I input something silly like that, than to have to resuscitate it. That is all. That level of math is not that impressive to brake the machine.

thank you.


RE: Probable bug - cyrille de brébisson - 01-20-2016 06:16 AM

Hello,

Infinite recursion detection is not as easy as it sounds unfortunately.
In the calculator, Un is, more or less, a program. Like a user function.

How would the computer detect that Function(n) is infinitely recursive?
Testing that there are multiple calls in the stack for the same function with the same arguments sounds like a good idea, BUT it has some drawbacks.
1) It is quite slow and would/could slow down the calculator significantly.
2) Because functions can use global variables, the fact that a function calls itself with the same arguments recursively does not always mean that it is infinitely recursive. For example:

Count= 10;
export rec(a)
if Count:= Count-1 then
rec(a);
end;
return a+1;
end;

This function is NOT infinitely recursive, but it would be very hard for the program elevator to detect it.

It would be nice to have some type of detection nevertheless, I agree...

Cyrille


RE: Probable bug - Gerald H - 01-20-2016 08:19 AM

(01-20-2016 06:16 AM)cyrille de brébisson Wrote:  Hello,

Infinite recursion detection is not as easy as it sounds unfortunately.
In the calculator, Un is, more or less, a program. Like a user function.

How would the computer detect that Function(n) is infinitely recursive?
Testing that there are multiple calls in the stack for the same function with the same arguments sounds like a good idea, BUT it has some drawbacks.
1) It is quite slow and would/could slow down the calculator significantly.
2) Because functions can use global variables, the fact that a function calls itself with the same arguments recursively does not always mean that it is infinitely recursive. For example:

Count= 10;
export rec(a)
if Count:= Count-1 then
rec(a);
end;
return a+1;
end;

This function is NOT infinitely recursive, but it would be very hard for the program elevator to detect it.

It would be nice to have some type of detection nevertheless, I agree...

Cyrille

Is the problem here one of INFINITE recursion?

The matter seems to have been dealt with in the HP 38G.


RE: Probable bug - jefierro - 01-20-2016 02:04 PM

Cyrille

Thanks so much for the effort, I wish I could do more to help than to nag about this. Good luck with everything.