HP Forums
[TI-73, TI-83, TI-86] Strange implied RETURN behavior - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not remotely HP Calculators (/forum-9.html)
+--- Thread: [TI-73, TI-83, TI-86] Strange implied RETURN behavior (/thread-14325.html)



[TI-73, TI-83, TI-86] Strange implied RETURN behavior - watchmaker - 01-07-2020 04:52 PM

All TI calculators allow to omit RETURN at the end of a program executed as a subroutine, this RETURN is implied automatically at the eng of that program. I type this code:
Code:
PROGRAM:INTEGRAL
Prompt A:Prompt B
Prompt N:2^N->M
A->G:prgmFN:P->I
(B-A)/(2*M)->D
M->O
Lbl Z
G+D->G:prgmFN:I+P*4->I
G+D->G:prgmFN:I+P*2->I
DS<(O,1)
Goto Z
B->G:prgmFN:I-P->I
I*D/3->I
Pause I
Stop

PROGRAM:FN
1/sqrt(2*pi)*e^(-G^2/2)->P
Return
It's a simple Simpson's integration algorithm ported directly from a Citizen SRP-320. I take a=-1.96, b=1.96, m=2^9 or 2^11. And now the strangeness begins...
If I omit RETURN at the end, the calculation takes MORE time than with explicit RETURN. The difference is (at m=2^11) 13..15 seconds on a TI-86, 4 seconds on a TI-83, approx. 1 second on a TI-73 Explorer. The difference is very small, but it can be reliably measured and reproduced. Why does it happen?

PS, do other calculators (e. g. HP) have the possibility to omit RETURN? And does it affect the calculation time?


RE: [TI-73, TI-83, TI-86] Strange implied RETURN behavior - Hlib - 01-07-2020 08:21 PM

TI calculators are negligent about syntax. This slightly saves memory, sometimes allows you to do undocumented tricks. In cyclic computing, these tricks may slow down the program, as mentioned long ago on the TI-forum. Here are some examples for TI-83.
{1,2,3->AB instead of {1,2,3}->LAB
DelVar_AB->C instead of DelVar_A:B->C
If_B:5->C ... If_B<>0:Then:5->C
For(A,1,B,C:End ... For(A,1,B,C):End and so on.


RE: [TI-73, TI-83, TI-86] Strange implied RETURN behavior - Csaba Tizedes - 01-07-2020 08:56 PM

OFF Simpson method on TIs: one of the most creative way /OFF

Csaba


RE: [TI-73, TI-83, TI-86] Strange implied RETURN behavior - toml_12953 - 01-08-2020 03:31 PM

(01-07-2020 08:56 PM)Csaba Tizedes Wrote:  OFF Simpson method on TIs: one of the most creative way /OFF

Csaba

Thanks for the link! There's some good information in that paper. The programs aren't too hard to convert to other machines.


RE: [TI-73, TI-83, TI-86] Strange implied RETURN behavior - Csaba Tizedes - 01-08-2020 04:20 PM

(01-08-2020 03:31 PM)toml_12953 Wrote:  Thanks for the link! There's some good information in that paper. The programs aren't too hard to convert to other machines.

If you interested, check this one: Stewart calculus TI-89/92 version and TI-83 version.

Both of them really valuable.

Csaba