PC-1211, PC-1250, etc. TVM
|
06-07-2024, 01:45 AM
(This post was last modified: 06-18-2024 09:52 AM by Albert Chan.)
Post: #28
|
|||
|
|||
RE: PC-1211, PC-1250, etc. TVM
(06-06-2024 11:34 PM)dm319 Wrote:(06-06-2024 12:27 AM)Albert Chan Wrote: And, many thanks to your examples. Yes, code had issue with example 5 (close to 0% bug). Plus42 should have this fixed soon. (issue sent) Plus42 previous version, secant's method did hang for some cases. Now, with true Newton's method and edge guess, this issue goes away. Here is closer to Plus42 do_i_pct_yr(), termination criteria based from Y, not I It does not relied on quadratic convergence, but finite ULP's: ULP(FNF) ≥ ULP(M) Rate search will not get stuck, even if no solution exist. 10 INPUT "B,N,P,M,F? ";B,N,P,M,F 12 IF B THEN P=P+M @ F=F-M ! end mode 14 IF ABS(P)>ABS(F) THEN X=F @ F=-P @ P=-X @ N=-N ! time reversed 20 DEF FNZ(I,A,B,C) @ D=(A+B)/2 @ B=A*C @ FNZ=A+M+(D+B)*I @ D=D+2*B @ END DEF 30 DEF FNF(I) @ IF 1+N*I*I=1 THEN FNF=FNZ(I,(P+F)/N,P-F,(N*N-1)/12*I) @ END 40 S=EXPM1(LOGP1(I)*N) @ D=(P+F)/S*(1-N*(S+1)/(S+S/I))+P 50 FNF=((P+F)/S+P)*I+M @ END DEF 60 I=M/F @ Y=FNF(I) ! "smallest" edge guess 70 DISP 100*I,Y @ H=-Y/D @ I=I+H @ Y0=Y @ Y=FNF(I) 80 IF SGN(Y0)=SGN(Y) AND ABS(Y0)>ABS(Y) THEN 70 90 DISP 100*I,Y @ J=I-Y/D/2 @ DISP 100*J ! half-correction Code: >run ! 1 Update: 1. Small rate branch test (1+I=1) --> (1+N*I*I=1) Small rate branch does quadratic fit, not suitable for huge compounding effect. 2. time-symmetry to keep size of P small, possibly less cancellation error. With this change, "smallest" edge rate is simply M/F 3. Final Newton correction cut in half, to reduce error radius. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 8 Guest(s)