Post Reply 
HP49-50G: help for recursive
02-02-2024, 04:27 PM
Post: #3
RE: HP49-50G: help for recursive
FYI, FNL(X) code does not need recursion.

At the time, I try to make FNL(X) simple, recursion with a base case.
I did not consider when to switch to fast-path, LOGP1(X)-X

Cas> fnl(x) := ln(1+x)-x
Cas> x1 := fsolve(fnl(x)=-0.1, x=0.4)       → 0.516221161425
Cas> x2 := fsolve(fnl(x)=-0.1, x=-0.4)      → -0.383183168208

If x is outside x1 .. x2, we don't have catastrophic cancellations. Try it!

FNL base case = log1p_sub_tiny(x), abserr ≈ -1/176679360 * (x/(1+x/2))^15

Cas> abserr(x) := -1/176679360 * (x/(1+x/2))^15
Cas> abserr(x1) / fnl(x1)      → 8.90366916672e−14
Cas> abserr(x2) / fnl(x2)      → -7.75261380424e−13

Relative error below machine epsilon.
FNL(X) recursion replaced with direct fast-path:

200 DEF FNL(X) ! = ln(1+X) - X, but more accurate
210 IF X<-.3832 OR X>.5163 THEN FNL=LOGP1(X)-X @ GOTO 250
220 X2=X/(X+2) @ X4=X2*X2
230 X4=X4*(5005-X4*(5082-X4*969))/(15015-X4*(24255-X4*(11025-X4*1225)))
240 FNL=X2*(X4+X4-X)
250 END DEF
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:27 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: 1 Guest(s)