▼
Posts: 12
Threads: 1
Joined: Jun 2010
I've put together a new HP-15C simulator at http://hp15c.com. It does almost everything, with some minor exceptions as noted on the About page. I'm continuing to work on it to implement the missing bits, so expect updates.
Please try it out - feedback, bug reports, and even contributions are welcome!
▼
Posts: 2,247
Threads: 200
Joined: Jun 2005
Greg,
I checked the SOLVE feature with my usual test function, and your simulator came through with flying colors.
I want to salute your valiant effort to create an HP-15C simulator for browsers. Not an easy job, especially if you are using Javascript (are you?).
Namir
Edited: 22 June 2010, 8:59 a.m.
▼
Posts: 12
Threads: 1
Joined: Jun 2010
Thanks! It is indeed written in Javascript (which is a pretty capable language, all things considered). The "Source" link on the site links to the source repository if you want to have a look.
Posts: 22
Threads: 1
Joined: Mar 2010
SIN(PI = 3.14159265359) = 1.224646799e-16
SIN(3.14159265) = 3.589793029e-09
SIN(0.01) = 9.999833334e-03
SIN(PI-0.01) = 9.999833334e-03
TAN(355/226) = -7.497258179e+06
Very accurate trig. BTW, CHS doesn't work in EEX.
▼
Posts: 22
Threads: 1
Joined: Mar 2010
If unimplemented functions is used in looping program, for example, Solver and Integration, the simulator keeps showing error messages. I think this is a small problem.
Edited: 22 June 2010, 10:49 a.m.
Posts: 12
Threads: 1
Joined: Jun 2010
The trig functions come straight out of the Javascript "Math.*" library, so I can't claim any credit for their accuracy. :)
I'll add the CHS in EEX bug to the known issues list.
Posts: 536
Threads: 56
Joined: Jul 2005
some missing complex trigs.
also, try adding 0.1 ten times, then press H.MS to get 0.5960 opps!
large factorials go bad, also in FIX 9, you dont get the exponent.
otherwise neat!
keep up the good work.
▼
Posts: 12
Threads: 1
Joined: Jun 2010
Thanks! The missing complex trig functions are noted on the known issues list. I'll have a look at that ->H.MS rounding problem.
I suspect the large factorials are due to some display rounding problems, especially with numbers slightly less than 1e100. Which number did you notice specifically?
▼
Posts: 536
Threads: 56
Joined: Jul 2005
▼
Posts: 12
Threads: 1
Joined: Jun 2010
Thanks, should be fixed now.
Posts: 282
Threads: 46
Joined: Jul 2005
Try 48.0 minus 47.8 then subtract 0.2 from the answer, the result should be zero - but it isn't so I know you are doing binary math.
Mike T.
▼
Posts: 12
Threads: 1
Joined: Jun 2010
Yes, that's true. I don't claim to be doing BCD math, that would be a substantial amount more work (but still possible). The simulator uses the native Javascript math library (as implemented in your browser) for all arithmetic.
▼
Posts: 536
Threads: 56
Joined: Jul 2005
is there a JS "decimal" type, or is that java only?
alternatively, you could pull a trick to "fix" these sorts of problems when working in binary as follows:
a + b = a <+> b if |a <+> b| >= eps*|a|
= 0 otherwise
where <+> represents computed addition rather than mathematical addition and eps is epsilon eg 10^-15
use the same idea for subtraction.
some real world calculators actually work in binary and they must do a trick like this, because i've tried to embarrass them with a binary rounding error and not been successful.
Posts: 225
Threads: 9
Joined: Jul 2008
Very nice!!! It even works using the browser on my Android phone.
▼
Posts: 1,619
Threads: 147
Joined: May 2006
I tried it on my iPad. Works too. However "test" reported errors:
Unimplemented: complex log
Fail: 45g)
Update: Test also failed on Firefox, fail: 3^.
Test now working on iPad. I just turned it sideways, reloaded the page so I could see the registers and test passed after 1 min 45 sec.
Hmmmm.... Just tested on iPad again, this time the orientation is the same as my failed test and it passed.
Hmmmm..... 4th try. I cannot get it to fail again on the iPad. BTW, no need for 'h' on the iPad, fingers work great. :-)
Update 2: Firefox fails repeatably (fail: 3^). iPad works every time now. Unsure what the original issue was.
Feature requests:
Sound (click), some type of visual button press notification.
Excellent work. Thanks!
Update 3:
I tested with Safari 5.0. Also failed like Firefox 3.6.3 with "fail: 3^". If I press test again I get the error above (complex log). BTW Safari screams compared to Firefox.
Chrome is also a screamer and passes, but a retest generates the "complex log" error.
I speculate the "complex log" error is erroneous.
Update 4:
Just got the "fail 3^" with Chrome. I cannot get Chrome to pass again without restarting Chrome. After that I got 3 passes and then non-stop fail 3^.
Edited: 22 June 2010, 6:30 p.m.
▼
Posts: 12
Threads: 1
Joined: Jun 2010
Wow, thanks for all the testing! I suspect many of those failures were due to the test function not resetting some critical flags (like the Complex flag) before running the test. Since the test ends with C set, this was sort of a problem. I've updated the script so the Test runs twice on my system, and would be interested to see whether that fixes the issues you saw.
▼
Posts: 1,619
Threads: 147
Joined: May 2006
Complex Log issue fixed, however:
Firefox 3.6.3, Safari 5.0 (OS/X 10.6.4):
The page at http://hp15c.com/ says:
fail: 3^
result: 352.00000000000006
expected: 352
diff: 2.220446049250313e-16
Chrome 5.0.375.70 (OS/X 10.6.4). Passed 3 times, then I closed the pop-up, clicked on the image again to get a new session and then test failed with:
The page at http://hp15c.com/ says:
fail: 3^
result: 352.00000000000006
expected: 352
diff: 2.220446049250313e-16
2.220446049250313e-16 is a familiar number with 64-bit floats. The "diff:" is the relative machine precision (i.e., the smallest number + 1 > 1), e.g.:
perl -e '$eps=1;while($eps+1>1){$eps/=2.0}$eps*=2;print"$eps\n"'
and
#include <stdio.h>
int main(void)
{
double eps = 1.0;
while(eps + 1.0 > 1.0)
eps /= 2.0;
eps *= 2.0;
printf("Epsilon is %.14e\n", eps);
}
yield:
2.22044604925031e-16
Rounding issues?
Why this works then fails on Chrome is odd. It should be consistent one way or another. Are all variables/arrays initialized? Does that question make sense for JavaScript?
Edited: 23 June 2010, 8:50 a.m.
▼
Posts: 12
Threads: 1
Joined: Jun 2010
The nondeterministic behaviour is indeed odd. I haven't seen that on any of the browsers I've tried, but I'll investigate.
Posts: 850
Threads: 10
Joined: Mar 2009
And on my Nokia 5800!! Just fits in on Full Screen mode.
Posts: 4,587
Threads: 105
Joined: Jul 2005
Good work!
Just pressing EEX without any preceding digit will not execute properly. You may even end with one stack level in a different format, i.e. displaying less decimals.
▼
Posts: 12
Threads: 1
Joined: Jun 2010
Indeed, that does look like it's doing the wrong thing. Will fix!
Posts: 320
Threads: 59
Joined: Dec 2006
Nice simulator. Through trial and error I found that values can be as large as 1x10^308. Though only the last two digits are displayed in the exponent, all three are actually still there because if you Log the value you get 308.
This means for large factorials (or for any large number) the integer part of the log of the answer is the correct exponent. For factorials I believe you can go up to 170! which shows
7.2574 06
But logging the number shows the exponent is actualyl 306. Possibly an improvement over an actual 15C, as long as you are aware of this when dealing with large numbers (like e^500).
CHUCK
Edited: 23 June 2010, 1:58 p.m.
▼
Posts: 12
Threads: 1
Joined: Jun 2010
Good catch - that's one of the situations I alluded to in the fine print, where "the numeric display is known to be totally wrong". :)
Behind the scenes, the calculator simulator uses the native Javascript Math library as implemented in your browser, which has the IEEE 754 double precision exponent range of approximately -308 to 308. I plan to detect such out of bounds display (beyond -99 to 99) and blink the result as a real 15C would do, rather than attempt to improve upon it.
Posts: 282
Threads: 46
Joined: Jul 2005
Very cool - looks great and the buttons move too.
Mike T.
Posts: 119
Threads: 18
Joined: Feb 2007
Please don't take me as a troll, because I'm honestly curious (plus a huge fan of the 15c).
Ignoring (a) the joy of creating such an application, and (b) the joy of dinking around with such an application, does anyone find that web-based calculator sims like this have practical application?
Loading it on a webphone sounds semi-practical ... but not nearly as practical as a native RPN calculator app. IMHO, most of these web apps are missing the features that make them truly useful, e.g., copying/pasting the results from the calculator into another app.
If I'm missing something, please enlighten me!
Edited: 23 June 2010, 4:53 p.m.
▼
Posts: 12
Threads: 1
Joined: Jun 2010
I think the idea of calculator simulators does not necessarily lean toward the "useful" side. Although some enthusiasts (like me and others that are probably found here) will use a simulator as their desktop calculator for nostalgic reasons (or even to provoke questions from curious bystanders), I don't think they are intended to be general purpose replacements for a fully functional calculator program or service.
For the 15C specifically, all of the "advanced" functions offered (complex, matrix, integration, solver) are provided in a much more usable, useful, and practical way by other services such as Wolfram Alpha. Surely you're aware of how tedious it is to actually enter matrix data into a 15C, for example.
Having said that, creating a web app does not preclude also creating a desktop app. A web user interface is an easy, quick, and widely accessible way of getting code out there that people can run instantly. The code is written in JavaScript, which is one of the most portable languages around today. I wouldn't rule out creating a corresponding application for desktop or mobile use. In fact, since it's open source, I would even encourage that!
I hope you enjoy the calculator simulators. That's what it's all about.
▼
Posts: 119
Threads: 18
Joined: Feb 2007
Thanks for your thoughts. Simulators like this definitely put a smile on my face (I especially like the web-based slide rule simulators), but I wasn't sure if there was something more to it than the fun/novelty.
I also use a 15c simulator (application) as a calculator in Mac OS X, but it has the added advantage of being able to give/receive data via copy/paste, which I use routinely. (IIRC, it will also save/load programs to disk, although I've never used that feature since, as I'm already using a computer, it's typically easier to write the code I need in something else.)
Edited: 24 June 2010, 1:41 p.m.
Posts: 193
Threads: 10
Joined: Aug 2009
Nice job!
The PSE function needs some attention - looks like it puts the X register up on the display, but doesn't really pause to show it.
Cheers,
Bob
▼
Posts: 12
Threads: 1
Joined: Jun 2010
Good catch, I had that disabled for the self-test. I'll find a better way to handle that within the test, and enable PSE for interactive use.
Posts: 735
Threads: 34
Joined: May 2007
Thanks for the contribution. What do you think, how difficult would it be to port Eric Smith's Nonpareil to JavaScript instead?
Best regards
Thomas
|