PC-1211, PC-1250, etc. TVM
|
06-05-2024, 12:34 PM
Post: #21
|
|||
|
|||
RE: PC-1211, PC-1250, etc. TVM
To make the post more clearly, I quoted the code used here
(06-05-2024 01:05 AM)Albert Chan Wrote: 10 INPUT "B,N,P,M,F? ";B,N,P,M,F @ B=B*M Since Sharp does not have EXPM1, LOGP1, lets try without them. For good measure, we also report the next iteration. >20 DEF FNF(I) @ S=1-(1+I)^(-N) >70 DISP (I-Y/D)*100 >run B,N,P,M,F? 0,360,0,-1000,1e6 .313028391431 504.47069099 .471270710728 62.96905505 .497374290313 1.51995026 .498036167469 .00095736 .498036584886 -.0000025 .498036583796 Final I is an improvement ... but it is really luck. Garbage in, Garbage out. More Newton iterations suggested we only have 8 to 9 digits accuracy. .498036583796 .498036583626 .498036583308 .49803658459 .498036583243 ... One way is to correct for S (1+I) error. (1+I)^(-n) = (1+I+ε)^(-n) * (1 + ε/(1+I)) ^n ≈ (1+I+ε)^(-n) * (1 + n*ε/(1+I)) >20 DEF FNF(I) @ X=1+I @ S=X^(-N) @ S=1-S-N*(X-1-I)/X*S >run B,N,P,M,F? 0,360,0,-1000,1e6 .313028391431 504.47068755 .471270710304 62.96905734 .497374290775 1.51994785 .498036166884 .00095668 .498036584005 .00000001 .498036584009 Much better, but S calculation is messy. A novel way is to set ε=0 !!! >20 DEF FNF(I) @ S=1-(1+I)^(-N) >50 H=-Y/D @ I=I+H+1-1 @ Y=FNF(I) ! Newton's method >run B,N,P,M,F? 0,360,0,-1000,1e6 .313028391 504.47068892 .47127071 62.96905807 .497374291 1.51994733 .498036167 .00095642 .498036584 .00000002 .498036584009 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 20 Guest(s)