Live data from Hacker News

Show HN: Kalk, A calculator with math syntax, complex numbers

kalk.strct.net

61–70 of 90 posts

Re: Show HN: Kalk, A calculator with math syntax, complex numbers

#61
post #19

This is somewhat similar to my project at https://calcula.tech , although the usecase is a bit different. There are a few other calculators around that use Rust + WASM which is kind of interesting

Very cool, I'm building a similar project atm as well (not ready to share, but you could dig it up easily), the latex reprinting of input is an interesting twist that I'm sure many people will appreciate.

I am afraid this domain is a prime nerd-sniping range, because there are so many variations on building a better, more interactive calculator. No profits here besides learning and great fun!

Re: Show HN: Kalk, A calculator with math syntax, complex numbers

#62
I immediately found a few Unicode features I hoped were supported but aren’t.

Superscripts: firstly numerals, like 3² = 9, but ideally then letters as well, e.g. 3ⁱ = 3^i. Might be suitable to support superscripts to define nth roots, too, e.g. ⁵√. tan¯¹ can be a thing too.

Subscripts: same deal; log₂ 31 = log(31, 2).

Proper arithmetic operators: times (×), minus (−), division (÷). Also fraction slash (⁄), which can be preceded and succeeded either by normal numerals (e.g. 12⁄34) or by superscripts and subscripts (e.g. ⁵⁶⁄₇₈). (Full font support for fraction slash is weak, but generally tolerable even if imperfect.) Also the prebaked fractions like ½ and ⅜.

Also mixed fractions: I reckon 1 2/3 should be parsed as 1+2/3, not 12/3. Them Unicode fractions can join in here too, with 1⅔ (using a prebaked fraction) being 1+2/3, or 1²³⁄₄₅ (using superscript, fraction slash, subscript) being 1+23/45.

Cubic and quartic roots: ∛ and ∜.

At this point it’s worth just looking through the whole Symbol, Math Unicode category and implementing everything applicable. Hmm, set operations, lots of fun symbols there.

Lots of fun spaces too, e.g. where I wrote log₂ 31 earlier I wanted to use NARROW NO-BREAK SPACE after the ₂, but alas, HN normalises it to a plain old space. That space gets used as a number grouping separator especially, avoiding the whole ,/. localisation problem without being too wide.

Re: Show HN: Kalk, A calculator with math syntax, complex numbers

#63
For what it’s worth, my first session went like this:

  >> e^iπ+1
  2.6974097548 + 2.6435590641i
  >> e^iπ
  1.6974097548 + 2.6435590641i
In fairness, I still don’t know where “e” comes from in complex number notation. The transition from cos(angle) + i sin(angle) seems to become “e^i(angle), lol” and no one explains it further. Before I started doing signal processing, I too would have thought that e^i pi is something like 1.69 + 2.64, so it’s correct, in a certain sense. But perhaps not the common mathematical sense.

EDIT: Ah, I see the problem. I suspected that e^iπ was being turned into πe^i incorrectly, but when I typed the open parenthesis for e^() and put my cursor inside it, typing "i" resulted in e^i() rather than e^(i). So it was impossible to parenthesize correctly, and I assumed e^iπ had the usual meaning.

Re: Show HN: Kalk, A calculator with math syntax, complex numbers

#64
post #50

For fun, try to run this: `2 + 2 * 10%` in all calculators you have access to: on you phone, on your desktop, in kalk. As they say, "the answer will surprise you" :)

The calculator that comes with MIUI 12 (Xiaomi phone) writes everything as you type, like you'd expect. But, the moment you type `%`, it instead replaces `10` with `0.1`. So in the end the screen shows: 2+2x0.1 = 2.2 I guess not as surprising as you expected :-]

I did say "in all calculators you have access too, including kalk" ;)

https://news.ycombinator.com/item?id=27336530

Re: Show HN: Kalk, A calculator with math syntax, complex numbers

#65

For fun, try to run this: `2 + 2 * 10%` in all calculators you have access to: on you phone, on your desktop, in kalk. As they say, "the answer will surprise you" :)

$ units You have: 2 + 2 * 10% Definition: 2.2 ITYM "the answer may surprise you", and in this case it did not.

I did say "in all calculators you have access too, including kalk" ;)

https://news.ycombinator.com/item?id=27336530

Re: Show HN: Kalk, A calculator with math syntax, complex numbers

#66

For what it’s worth, my first session went like this: >> e^iπ+1 2.6974097548 + 2.6435590641i >> e^iπ 1.6974097548 + 2.6435590641i In fairness, I still don’t know where “e” comes from in complex number notation. The transition from cos(angle) + i sin(angle) seems to become “e^i(angle), lol” and no one explains it further. Before I started doing signal processing, I too would have thought that e^i pi is something like…

It's the exponential notation for complex numbers, see for example https://tutorial.math.lamar.edu/Extras/ComplexPrimer/Forms.a...

Re: Show HN: Kalk, A calculator with math syntax, complex numbers

#67

For what it’s worth, my first session went like this: >> e^iπ+1 2.6974097548 + 2.6435590641i >> e^iπ 1.6974097548 + 2.6435590641i In fairness, I still don’t know where “e” comes from in complex number notation. The transition from cos(angle) + i sin(angle) seems to become “e^i(angle), lol” and no one explains it further. Before I started doing signal processing, I too would have thought that e^i pi is something like…

The derivation comes from Taylor series expansion of the exponential function e^x = 1 + x/1! + x^2/2! + x^3/3! + …

You can throw together a program that will show numerically that this both converges to e^x for real x and that e^ix converges to cos(x)+i*sin(x). You can also find proofs online I’m sure.

Re: Show HN: Kalk, A calculator with math syntax, complex numbers

#68
post #66

For what it’s worth, my first session went like this: >> e^iπ+1 2.6974097548 + 2.6435590641i >> e^iπ 1.6974097548 + 2.6435590641i In fairness, I still don’t know where “e” comes from in complex number notation. The transition from cos(angle) + i sin(angle) seems to become “e^i(angle), lol” and no one explains it further. Before I started doing signal processing, I too would have thought that e^i pi is something like…

It's the exponential notation for complex numbers, see for example https://tutorial.math.lamar.edu/Extras/ComplexPrimer/Forms.a...

That post proves the point: it jumps from "use cos(t) + i sin(t)" to "use e^it" with zero explanation about why it's related to 2.718281828...

The reason I posted my comment is because e^(i pi) is obviously supposed to be -1+0j. But I see now that I was using the calculator incorrectly (I was doing the equivalent of πe^i) but there was a bug in the parenthesis operator preventing me from typing it that way on mobile.

Re: Show HN: Kalk, A calculator with math syntax, complex numbers

#69
post #51
post #45

This looks extremely useful, even though currently makes quite a few mistakes, as noted by others. A few features that could be nice: 1) It handles 1 000 000 * 3 just fine, but returns 3000000. So it would be nice if it would format output as 3 000 000 as well for readability. At least as an optional setting (even though I have no idea why someone wouldn't want that). 2) Some way of referencing last result. Often you…

These are some great suggestions! I should absolutely make it add spaces, can't believe I didn't think of that. Also, it actually does have a way to reference the last result, I forgot to document it. It's a variable called "ans"! The last thing, yeah, that would be neat. I'll think about it...

This is a really great calculator, will definitely be using it! FYI I noticed there is a very similar product with the same name: https://kalk.dev/

Re: Show HN: Kalk, A calculator with math syntax, complex numbers

#70
post #67

For what it’s worth, my first session went like this: >> e^iπ+1 2.6974097548 + 2.6435590641i >> e^iπ 1.6974097548 + 2.6435590641i In fairness, I still don’t know where “e” comes from in complex number notation. The transition from cos(angle) + i sin(angle) seems to become “e^i(angle), lol” and no one explains it further. Before I started doing signal processing, I too would have thought that e^i pi is something like…

The derivation comes from Taylor series expansion of the exponential function e^x = 1 + x/1! + x^2/2! + x^3/3! + … You can throw together a program that will show numerically that this both converges to e^x for real x and that e^ix converges to cos(x)+i*sin(x). You can also find proofs online I’m sure.

Why do it numerically? Show that e^ix converges, then you can reorder the sums, grouping the odd and even terms you get series expansions for cos(x) and i sin(x).
Post reply on HN