Post Reply 
PC-1211, PC-1250, etc. TVM
06-06-2024, 12:27 AM (This post was last modified: 06-06-2024 02:24 PM by Albert Chan.)
Post: #24
RE: PC-1211, PC-1250, etc. TVM
Hi, robve

If you have good EXP, LN, you can build accurate EXPM1 LNP1

(02-04-2019 07:28 PM)Dieters formula Wrote:  expm1(x) = (u-1) - (ln(u) - x) * u, where u = exp(x), rounded

log1p( x ) = ln(u) - ((u-1) - x) / u, where u = 1+x, rounded

And, many thanks to your examples.
I actually discovered a Plus42 bug, for rate very close to 0%.

Code:
10 INPUT "B,N,P,M,F? ";B,N,P,M,F @ B=B*M
15 DEF FNZ(I,A,B,C) @ D=(A+B)/2 @ B=C*A @ FNZ=A+M+(D+B)*I @ D=D+2*B @ END DEF
20 DEF FNF(I) @ IF 1+I=1 THEN FNF=FNZ(I,(P+F)/N,P-F+B+B,(N*N-1)/12*I) @ END
25 S=-EXPM1(LOGP1(I)*-N) @ D=(P+F)/S*(1-N*(1-S)/(S+S/I))+(B-F)
30 FNF=(P+F)*I/S+(B-F)*I+M @ END DEF
40 X=(ABS(P)<ABS(F))*(P+F)-B @ I=M/(X-P) ! edge rate
50 Y=FNF(I) @ DISP 100*I,Y @ H=-Y/D @ I=I+H @ IF I+H*H<>I THEN 50
60 DISP 100*I

With FNF(I ≈ 0) added, updated version handled all your examples.
Some F values adjusted to true 10 digits accuracy, to test for I round-trip

Code:
>run ! 1
B,N,P,M,F? 1,40,900,-40,-1000
 4.16666666667       -5.1783387869
 4.7524512828        -.0080716937
 4.75336718645       -.0000000187
 4.75336718857

>run ! 2
B,N,P,M,F? 1,40,900,-400,-1000
 66.6666666667       -66.666666756
 79.9999999644       -.000000183
 80.000000001

>run ! 3
B,N,P,M,F? 0,365*24*60*60,0,-0.01,331667.0067
-3.01507228575E-6     6.2977646195E-3
-1.1099216591E-7      7.022277322E-4
 3.07577857109E-7     1.52692722E-5
 3.17093002072E-7     7.8839E-9
 3.17097920053E-7
>res * n
 10.0000000068
 
>run ! 4
B,N,P,M,F? 0,365*24*60,0,-0.01,5527.7829015
-1.80904354932E-4     6.2977549796E-3
-6.659604136E-6       7.022284099E-4
 1.84546671658E-5     1.52693549E-5
 1.90255801086E-5     .000000007884
 1.90258751918E-5
>res * n
 10.0000000008

>run ! 5
B,N,P,M,F? 0,365*24*60,0,-0.01,5260.382426
-1.90100247286E-4     .005827435363
-2.255093023E-5       6.131837705E-4
-1.23294301E-7        1.15811689E-5
 3.16928063661E-7     4.4651E-9
 3.17097921621E-7
>res * 60*n
 10.0000000563
 
>run ! 6
B,N,P,M,F? 0,32,-999999,0,1000000
 0                    .03125
 3.12500161133E-6     0
 3.12500161133E-6
 
>run ! 7
B,N,P,M,F? 0,360,0,-1000,1000000
-.1                   2306.3389698
 .313028391458        504.47068745
 .47127071031         62.96905733
 .497374290777        1.51994785
 .498036166886        .00095669
 .498036584011

Update: Code showed initial edge rate as well (previously hidden)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
PC-1211, PC-1250, etc. TVM - Dave Britten - 03-30-2021, 04:58 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 03-30-2021, 05:07 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 04-01-2021, 05:50 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 05-29-2024, 09:17 PM
RE: PC-1211, PC-1250, etc. TVM - dm319 - 05-31-2024, 01:11 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-01-2024, 01:07 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-02-2024, 09:46 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-03-2024, 06:44 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-04-2024, 12:26 AM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-04-2024, 11:35 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-05-2024, 07:16 PM
RE: PC-1211, PC-1250, etc. TVM - dm319 - 06-05-2024, 10:06 PM
RE: PC-1211, PC-1250, etc. TVM - dm319 - 06-06-2024, 11:02 PM
RE: PC-1211, PC-1250, etc. TVM - dm319 - 06-08-2024, 06:19 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-08-2024, 09:21 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-09-2024, 12:06 AM
RE: PC-1211, PC-1250, etc. TVM - rprosperi - 06-09-2024, 01:22 PM
RE: PC-1211, PC-1250, etc. TVM - nickapos - 06-12-2024, 05:20 AM
RE: PC-1211, PC-1250, etc. TVM - Albert Chan - 06-06-2024 12:27 AM
RE: PC-1211, PC-1250, etc. TVM - dm319 - 06-06-2024, 11:34 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-07-2024, 02:30 AM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-08-2024, 08:38 PM
RE: PC-1211, PC-1250, etc. TVM - dm319 - 06-09-2024, 10:12 AM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-11-2024, 07:13 PM
RE: PC-1211, PC-1250, etc. TVM - dm319 - 06-11-2024, 10:32 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-12-2024, 12:29 AM
RE: PC-1211, PC-1250, etc. TVM - dm319 - 06-12-2024, 12:45 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-12-2024, 04:58 PM
RE: PC-1211, PC-1250, etc. TVM - dm319 - 06-22-2024, 12:12 PM
RE: PC-1211, PC-1250, etc. TVM - robve - 06-22-2024, 08:39 PM



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