thomasokken / plus42desktop Goto Github PK
View Code? Open in Web Editor NEWPlus42 : An Enhanced HP-42S Calculator Simulator
Home Page: https://thomasokken.com/plus42/
License: GNU General Public License v2.0
Plus42 : An Enhanced HP-42S Calculator Simulator
Home Page: https://thomasokken.com/plus42/
License: GNU General Public License v2.0
This is from core_commands9.cc do_i_pct_yr()
phloat i = 0.0001; // Arbitrary starting guess...
I think I have a robust guess for this.
First, what's wrong with above ?
NPMT=0 with unique rate solution, nothing's wrong.
Any reasonable guess (even crazy ones) will lead to the root.
Problem is when NPMT=0 had 2 rate roots.
NPMT curve look like a concave-up V.
Hard-coded rate might be located where slope of NPMT is small.
Newton's method may over-shoot it to no man's land.
If it overshoot to the right, possbily no harm is done.
If rate overshoot below −100%, code will break.
But, if we use rate guess from the edges, we are safe.
"Outside" guess for concaved-up curve, Newton's method never overshoot.
lua> n, pv, pmt, fv = 10, 50, -30, 80
lua> g = loan_rate(n,pv,pmt,fv, 0.0001) -- hard-coded guess
lua> g(), g()
-2.0050595733488947 -NaN -NaN
lua> pmt/fv, pmt/-pv -- rate edges
-0.375 0.6
lua> g = loan_rate(n,pv,pmt,fv, pmt/fv) -- low rate edge
lua> g(), g(), g()
-0.3689508127377895 -0.36893369888346206 -0.3689336987417774
lua> g = loan_rate(n,pv,pmt,fv, -pmt/pv) -- high rate edge
lua> g(), g(), g()
0.5846625273989696 0.5846195530179824 0.5846195526622099
For how rate edges are derived:
https://www.hpmuseum.org/forum/thread-18359-post-160156.html#pid160156
From core_commands9.cc
static phloat tvm_eq(phloat i) {
phloat pmt = tvm_pmt;
if (tvm_m)
pmt *= 1 + i;
if (i == 0)
return pmt + (tvm_pv + tvm_fv) / tvm_n;
else
return pmt + ((tvm_pv + tvm_fv) / expm1(tvm_n * log1p(i)) + tvm_pv) * i;
}
Let phloat tvm_m = tvm_pv + (mode==1) * tvm_pmt, above is simplified.
(I have not studied mode ranges, if it is just 0 or 1, remove ==1 part)
It is calculated outside rate search loop, thus also more efficient.
It is based from identity:
loan_rate(n, pv, pmt, fv, mode=1) = loan_rate(n, pv+pmt, pmt, fv-pmt, mode=0)
Revised tvm_eq():
static phloat tvm_eq(phloat i) {
if (i == 0)
return tvm_pmt + (tvm_pv + tvm_fv) / tvm_n;
else
return tvm_pmt + ((tvm_pv + tvm_fv) / expm1(tvm_n * log1p(i)) + tv_m) * i;
}
Regarding TVM I%YR rate search ...
A rare bug, when initial guess, or one of the iteration, is very close to 0%
Catastrophic cancellations could mess up derivatives, see here
Instead of special cased to test exactly i=0, we widen it:
local eps, f = i*i
if 1+eps==1 then
local a, b = (pv+fv)/n, pv-fv
local fp, fpp = (a+b)*0.5, (n*n-1)*a/6
f, fp = (a+pmt)+fp*i, fp+fpp*i
eps = -f / fp
Above simply use an approximation, for tiny i
f(i) ≈ f(0) + f'(0)*i
f'(i) ≈ f'(0) + f''(0)*i
I cannot find any indication of 1.0.11's new "A...F" function anywhere in the Plus42 UI/UX. I can't find it in CATALOG, nor ASSIGN-able, and am not sure where i should be looking (or if it somehow isn't available). Please advise?
Thanks as always for all the hard work on Free42 and Plus42, it is very greatly appreciated!!
-John W
The default font can be a bit difficult to read (3's vs 9's, for example), so it would be great if we could adjust the sizing of the font within the display. Ideally, if we could select a different font (SwissMicros forums have a few donations worth exploring), that'd be even better.
I looked extensively in the docs for Free42 and Plus42 because I really believed there was already something available in layout settings or such, but if such settings exist, I was unable to locate them. Unrelated, but a single consolidated Plus42 manual (instead of a delta from Free42) would be helpful, and likewise w.r.t. layout file formatting.
Unclear if intentional or not, but by default as of 1.0.11, the top (blank) row of buttons in Plus42 now do the same as the buttons in the row "Σ+" through "XEQ", which is surprising, unexpected (and arbitrary) behavior. I do not recall this being their behavior in 1.0.10 or prior, but could be misremembering in that regard, feels like new behavior in 1.0.11.
Please advise if intentional, and if so, would be nice if there was a preference to have them do nothing instead (until assigned).
P.S. Thanks for "A..F" function!
-John Wiederhirn
Fixed: DisplaySize needed to be exactly correct.
skin is here
(btw I would probably* like the display lines to be changeable from the menu, as my default choice is 3 lines i.e. I can see x,y when the menu is displayed, but sometimes would like it longer)
Trying to make an existing skin work with plus42, and 3 lines. (linux)
If I don't specify DisplaySize, then it stretches the whole calculator longer.
But if I do specify it, and 3 lines, then the expanded zone appears to be the width of the pixel array only, and expands the screen area sown over the keyboard instead of making the calculator longer.
Skin: 0,0,320,460
Display: 12,18 2.25 3 caffbf 000000
DisplaySize: 22,3 20 3 3 #has the problem described
DisplaySize: 22,2 18 3 3 #works properly.
Hp50g: '2^3^4' EVAL, it produced 2^(3^4) ≈ 2.41785E24
Plus42: XSTR "2^3^4" PARSE EVAL, it produced (2^3)^4 = 4096
Is this worth fixing?
Since you've been adding features from other HP calculators to Plus42 I'm curious as to the possibility of backpacking CAS features from newer HP calculators?
Thanks and I appreciate all the work you've done on Free/Plus42!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.