Post Reply 
HP49-50G: help for recursive
02-02-2024, 04:48 PM
Post: #4
RE: HP49-50G: help for recursive
Hi, Gil

I am unclear which of your code (FNL, FNL2, FNL4) work.
Some examples would be nice.

Ignore the fact that FNL(X) does not need recursion (see previous post)
Ignore also global variables should really be local, as SUB program.

Here is how we simulate recursions for machine that does not support it, with a stack.

200 DIM S(99) @ DEF FNL(X) ! = ln(1+X) - X, but more accurate
210 FOR I=1 TO 99 @ IF ABS(X)<.4 THEN 230
220 X=X/(SQRT(1+X)+1) @ S(I)=X @ NEXT I ! fill stack
230 X2=X/(X+2) @ X4=X2*X2
240 X4=X4*(5005-X4*(5082-X4*969))/(15015-X4*(24255-X4*(11025-X4*1225)))
250 L=X2*(X4+X4-X)
260 WHILE I>1 @ I=I-1 @ X=S(I) @ L=L+L-X*X @ END WHILE ! undo stack
270 FNL=L @ END DEF

Again, this is for illustration only.
We don't want recursions (with rounding errors) when it is not needed.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP49-50G: help for recursive - Gil - 02-02-2024, 12:46 PM
RE: HP49-50G: help for recursive - Gil - 02-02-2024, 01:52 PM
RE: HP49-50G: help for recursive - Albert Chan - 02-02-2024 04:48 PM
RE: HP49-50G: help for recursive - Gil - 02-02-2024, 06:13 PM
RE: HP49-50G: help for recursive - Gil - 02-03-2024, 10:19 AM
RE: HP49-50G: help for recursive - Gil - 02-04-2024, 12:06 PM
RE: HP49-50G: help for recursive - Gil - 02-06-2024, 11:57 AM
RE: HP49-50G: help for recursive - DavidM - 02-06-2024, 01:14 PM
RE: HP49-50G: help for recursive - Gil - 02-06-2024, 01:29 PM
RE: HP49-50G: help for recursive - DavidM - 02-06-2024, 03:51 PM
RE: HP49-50G: help for recursive - Gil - 02-06-2024, 05:48 PM
RE: HP49-50G: help for recursive - DavidM - 02-06-2024, 08:51 PM
RE: HP49-50G: help for recursive - Gil - 02-06-2024, 08:53 PM



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