Live data from Hacker News

Show HN: AlexCalc, a scientific calculator with LaTeX equation display

alexbarry.github.io

11–20 of 21 posts

Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display

#11
post #9
post #7

Earlier quoted context omitted.

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…

> Also, do you mind if I ask how you are entering Greek letters directly? 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".

> 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.

Cool! Is this because you type a lot of Greek (or math)?

> My unpopular opinion is that typing "alpha" should compute the product of the five values, equivalent to "a^2lph".

I wouldn't call it an unpopular opinion, that's how my physical graphing calculator worked, though it only had single letter variable names. The programmer in me likes my current way, though the (nearly long gone) engineering student cringes when I have to write things like "i*2*pi*f".

If people were mostly universally happy with single letter variable names then I could probably switch to this. If they were space separated then it would be a fairly simple change (except for the way units works, is "1 s" 1 times variable s, or 1 second? This is why I don't support 1 m/s to mean metre per second, it means "1 metre divided by variable s". 1 metre per second is "1 m s^-1").

I tried to compromise by making the UI automatically enter a multiplication symbol when entering tokens that aren't valid.

Perhaps if I added an additional input layer when typing then this would be feasible. Maybe something like pressing a special character, then typing "alpha" will convert it to the alpha character, and non greek letter variables could be wrapped in quotes or square brackets or something.

The one thing that would be lost is the ability to name a variable "x2". Maybe that's fine since "x_2" would still work.

As an update on unicode parsing, I still think it should be easy, but I'm running into issues. I quickly tried https://stackoverflow.com/a/11255698/9596600 but I'm seeing this:

    terminate called after throwing an instance of 'std::regex_error'
      what():  Unexpected escape character.
I suspect I just need to dig in on how to use these extended regexes (and remove some of my existing regexes). This weekend I might have more time to try it.

Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display

#12
post #10
post #8

Earlier quoted context omitted.

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}

Wow, thanks. This is way more complex than I expected. When I started working on this I thought that I might want to switch to "binary coded decimal"[0] to avoid issues with inputs like (0.1 + 0.2 - 0.3). 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^(i pi) + 1` to be exactly 0, too (instead of something ugly like (-2 10^-16…

> When I started working on this I thought that I might want to switch to "binary coded decimal"[0] to avoid issues with inputs like (0.1 + 0.2 - 0.3).

If you want to go this route, there are standardized decimal floating points, e.g. https://en.wikipedia.org/wiki/Decimal64_floating-point_forma... (or the 128 bit version).

> And is there an implementation I could use?

Afaik Boehms implementation lived only in the Android source tree, i.e. https://android.googlesource.com/platform/packages/apps/Exac... . So to use that you'd need to extract and port them, which might be some effort.

There are all sorts of different approaches for doing calculations on real numbers. I think Johanssons work is particularly impressive in this domain, but I'm not sure if that is much use for a calculator like this: https://fredrikj.net/

Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display

#15
post #13

Nice project. It's pretty similar to my project CalcuLaTeX ( https://calcula.tech ) although I think the intended usecase is slightly different

Thanks! And that is so cool! It looks like the intended use case of this is to generate documents or short snippets of LaTeX, but not have to hard code the answers?

I wish I had something like this back when I actually wrote reports and stuff in LaTeX. Now I barely have any use case for my own calculator, except occasional unit conversions.

The use case that I had in mind for mine was electrical engineering students, where I had to often use complex numbers in polar form, in degrees, for circuit questions. My calculator at the time had no obvious way of entering polar complex numbers in degrees, I ended up typing things like `e^(i*angle/1r)`, where the r was "radian", and when the calculator was in degrees mode, "1 r" would evaluate to "180/pi".

It was also cumbersome to write long expressions for. It showed something like 24 characters per line, enough that I'd often get multi line expressions. These expressions would be full of brackets, and sometimes I'd hit enter and not be sure if I missed a bracket. (Hence my goal of having a LaTeX display to show you what you're entering).

Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display

#16
post #14

Sweet:) Nitpick: in dark theme, the fraction line didn't invert to white in 1/sqrt(2)

Thanks for letting me know, is this in the web version? If so, what browser? I tried Chrome and Firefox and I don't see this issue. I use a plugin to make sites dark ("Dark Reader") and it seems to work for my web calculator in Firefox.

Or is it Android? On my phone 1/sqrt(2) looks fine in "dark" and "very dark". If it doesn't for you, could you tell me what type of phone you have? I put some contact info in the "about" section of the app if you'd rather respond privately.

For dark mode on Android I just set the color and background-color attributes of the HTML display elements. (I didn't actually fully implement dark mode in the HTML version, though there are some commented out CSS files). But it's possible that something else is needed to work with MathJax in some cases.

Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display

#17
post #15
post #13

Nice project. It's pretty similar to my project CalcuLaTeX ( https://calcula.tech ) although I think the intended usecase is slightly different

Thanks! And that is so cool! It looks like the intended use case of this is to generate documents or short snippets of LaTeX, but not have to hard code the answers? I wish I had something like this back when I actually wrote reports and stuff in LaTeX. Now I barely have any use case for my own calculator, except occasional unit conversions. The use case that I had in mind for mine was electrical engineering students,…

Yeah, I made it to do my chemistry homework where a lot of problems were duplicated with different numbers. The truth is that it's not well tested outside of that though so it's hard to trust for complicated stuff. I might end up using yours :)

Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display

#18
post #16
post #14

Sweet:) Nitpick: in dark theme, the fraction line didn't invert to white in 1/sqrt(2)

Thanks for letting me know, is this in the web version? If so, what browser? I tried Chrome and Firefox and I don't see this issue. I use a plugin to make sites dark ("Dark Reader") and it seems to work for my web calculator in Firefox. Or is it Android? On my phone 1/sqrt(2) looks fine in "dark" and "very dark". If it doesn't for you, could you tell me what type of phone you have? I put some contact info in the "abo…

Chrome on Android, web version, the phone is set to dark mode, the browser inherits it. Pixel 5.

Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display

#19
post #18
post #16

Earlier quoted context omitted.

Thanks for letting me know, is this in the web version? If so, what browser? I tried Chrome and Firefox and I don't see this issue. I use a plugin to make sites dark ("Dark Reader") and it seems to work for my web calculator in Firefox. Or is it Android? On my phone 1/sqrt(2) looks fine in "dark" and "very dark". If it doesn't for you, could you tell me what type of phone you have? I put some contact info in the "abo…

Chrome on Android, web version, the phone is set to dark mode, the browser inherits it. Pixel 5.

Thanks a lot! I see now, I am able to reproduce the issue if I go into chrome://flags, search for "Auto Dark Mode for Web Contents", and select "Enabled with simple HSL-based inversion". Just choosing "Enabled" seemed to break the LaTeX entirely. (Please let me know if that isn't roughly what you did)

I don't know how I'll fix this (I've never really debugged mobile web specific stuff before), but I'll look into it this weekend.

There must be a way to fix it, since I don't see the issue when going to https://www.mathjax.org/#demo and entering something like this: $$\frac{1}{\sqrt{2}}$$

EDIT: I actually have no idea why this would be happening, unless there is some sort of metadata that I should be providing on the page to tell chrome how to enable dark mode on my content. I don't think I'm messing with the styling on the web version at all.

Re: Show HN: AlexCalc, a scientific calculator with LaTeX equation display

#20
post #19
post #18

Earlier quoted context omitted.

Chrome on Android, web version, the phone is set to dark mode, the browser inherits it. Pixel 5.

Thanks a lot! I see now, I am able to reproduce the issue if I go into chrome://flags, search for "Auto Dark Mode for Web Contents", and select "Enabled with simple HSL-based inversion". Just choosing "Enabled" seemed to break the LaTeX entirely. (Please let me know if that isn't roughly what you did) I don't know how I'll fix this (I've never really debugged mobile web specific stuff before), but I'll look into it t…

Hm I have dark mode enabled on the phone and then the chrome flag is just on default. How could I check which of the implementations this will select?

This is chrome 97.0.4692.98

I'd also think we move this from HN to some issue tracker?

https://github.com/alexbarry/AlexCalc/issues/2

Post reply on HN