Show HN: AlexCalc, a scientific calculator with LaTeX equation display
alexbarry.github.io
Show HN: AlexCalc, a scientific calculator with LaTeX equation display
1–10 of 21 posts
Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display
#2Available on:
* web (mobile or desktop): https://alexbarry.github.io/AlexCalc/
* Android: https://play.google.com/store/apps/details?id=net.alexbarry....
Some neat features:
* LaTeX equation display (I hated counting brackets on my old graphing calculators back in college, now I wouldn't have to if I wasn't ~10 years late in making this)
* variables (you can store variables with `1 + 2 -> x`, then access them `x^2 - 3`)
* unit operations, and unit conversions, e.g. `10 km / 2 minutes to mph`, or more fancily: `sqrt((3 kOhm + j*100 mH * 1000 kHz)/(1 S + j * 1 nF * 1000 kHz))`
* complex numbers (specifically focused on making it easy to enter complex numbers in polar form, in degrees, e.g. `5 angle 90`, but press the "degree" button)
* can enter input either via button presses or typing, so copying and pasting inputs works well
The core calculator parsing, evaluating, and LaTeX generation is in C++, with CMake build files. Using emscripten[0], this compiles to webassembly for the web version, and I can also compile this for Android and use JNI.
The library converting my generated LaTeX code to graphics is "MathJax"[1], a really nice browser library that I loved working with both in the web version and in the Android WebView.
I'm happy to receive any feedback at all. One big weakness currently are the syntax error messages, I haven't yet implemented a way to point to a particular position where an error occurs. If there is some nice parsing library that I could use instead, I might consider switching to that if it isn't too difficult. Currently the parsing uses a bunch of (fairly simple) regular expressions (e.g. check for number, check for optional unit, check for binary operator, add to stack, collapse stack. This ends up with a tree of nodes, and then this tree can either be evaluated or converted to LaTeX.)
I'm also interested in hearing any strategies for a decent cross platform UI. I didn't want to just include the HTML UI in a WebView on Android, since I figured it wouldn't be a great user experience. Originally I thought it would be small enough that I could just write two separate copies... but it turns out that there is a lot more UI code than I expected (automatically insert multiplication symbols on button presses, input history, storing "recently used units" when the button is pressed, etc...)
Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display
#3Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display
#4For choosing the desired output unit, press "alt" and the now shown "to units" button. Then enter the desired unit.
Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display
#5Hey, this is great! Units and LaTeX formatting are two things I use a lot.
I thought that it might be useful to use this application to generate TeX, so one feature I'm working on is to fine tune the output format (e.g. choosing the multiplication symbol, instead of \cdot, maybe \times or \,).
Thanks for trying it!
Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display
#6Hi all, as a hobby I've been developing a scientific calculator with some neat features. Available on: * web (mobile or desktop): https://alexbarry.github.io/AlexCalc/ * Android: https://play.google.com/store/apps/details?id=net.alexbarry.... Some neat features: * LaTeX equation display (I hated counting brackets on my old graphing calculators back in college, now I wouldn't have to if I wasn't ~10 years late in maki…
Would it be feasible to support unicode variables? Having to spell the greek letters seems a bit clunky. If I type them directly it gives a parsing error. Notice that in modern LaTeX (say, xetex or luatex) you can do that. No need to type \'e to get é like we did in the nineties.
Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display
#7Hi all, as a hobby I've been developing a scientific calculator with some neat features. Available on: * web (mobile or desktop): https://alexbarry.github.io/AlexCalc/ * Android: https://play.google.com/store/apps/details?id=net.alexbarry.... Some neat features: * LaTeX equation display (I hated counting brackets on my old graphing calculators back in college, now I wouldn't have to if I wasn't ~10 years late in maki…
Hey, it looks great, I love it! Would it be feasible to support unicode variables? Having to spell the greek letters seems a bit clunky. If I type them directly it gives a parsing error. Notice that in modern LaTeX (say, xetex or luatex) you can do that. No need to type \'e to get é like we did in the nineties.
Assuming C++ standard regex supports unicode, then this should be easy enough. I never thought to try this. I'll see if I can implement it later today or this weekend. Do you think the spelled out "alpha" should map to the same thing as ""?
Also, do you mind if I ask how you are entering Greek letters directly? (e.g. are you a Greek speaker, using a Greek keyboard?) I'd like to better understand how people would like to use this. I'm happy to accommodate whatever I can, and I'm relying on people asking for it directly since I don't have any sort of tracking implemented. (The android version doesn't even request any INTERNET permission (or any permission).)
Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display
#8Hi all, as a hobby I've been developing a scientific calculator with some neat features. Available on: * web (mobile or desktop): https://alexbarry.github.io/AlexCalc/ * Android: https://play.google.com/store/apps/details?id=net.alexbarry.... Some neat features: * LaTeX equation display (I hated counting brackets on my old graphing calculators back in college, now I wouldn't have to if I wasn't ~10 years late in maki…
Right now 0.1+0.2-0.3 results = 2.775557562 \cdot 10^{-17}, which depending on your viewpoint is either expected or unexpected. Also (0.1+0.2)-0.3 is simplified to 0.1+0.2-0.3 for display, but results a different value = 5.551115123 \cdot 10^{-17}
Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display
#9Earlier quoted context omitted.
Hey, it looks great, I love it! Would it be feasible to support unicode variables? Having to spell the greek letters seems a bit clunky. If I type them directly it gives a parsing error. Notice that in modern LaTeX (say, xetex or luatex) you can do that. No need to type \'e to get é like we did in the nineties.
Thanks a lot for trying it and the feedback! Assuming C++ standard regex supports unicode, then this should be easy enough. I never thought to try this. I'll see if I can implement it later today or this weekend. Do you think the spelled out "alpha" should map to the same thing as " "? Also, do you mind if I ask how you are entering Greek letters directly? (e.g. are you a Greek speaker, using a Greek keyboard?) I'd l…
I've setup my keyboard (on linux) so that the CAPS-LOCK key acts as a "dead greek" composer. If I press "CAPSLOCK+a" it types "α", and so on.
> Do you think the spelled out "alpha" should map to the same thing as ""?
My unpopular opinion is that typing "alpha" should compute the product of the five values, equivalent to "a^2lph".
Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display
#10Hi all, as a hobby I've been developing a scientific calculator with some neat features. Available on: * web (mobile or desktop): https://alexbarry.github.io/AlexCalc/ * Android: https://play.google.com/store/apps/details?id=net.alexbarry.... Some neat features: * LaTeX equation display (I hated counting brackets on my old graphing calculators back in college, now I wouldn't have to if I wasn't ~10 years late in maki…
If you want to move beyond standard floats, this paper could be good starting point: https://dl.acm.org/doi/pdf/10.1145/3385412.3386037 Right now 0.1+0.2-0.3 results = 2.775557562 \cdot 10^{-17}, which depending on your viewpoint is either expected or unexpected. Also (0.1+0.2)-0.3 is simplified to 0.1+0.2-0.3 for display, but results a different value = 5.551115123 \cdot 10^{-17}
I haven't had a chance yet to read the full paper, but it talks about fixing trig issues too. Would this fix my (unfortunate) result for `e^(ipi) + 1` to be exactly 0, too (instead of something ugly like (-210^-16 + j1.22*10^-16)).
And is there an implementation I could use?
At some point I plan on open sourcing this code, so if I never manage to fix this then maybe someone else might someday do it. Originally I figured I could finish this whole project in a few months, especially after figuring out webassembly and discovering MathJax. But it ended up taking way longer than that, with little things constantly popping up that I wanted to fix before I could even think about sharing it.