[–] sharkdp link

Thank you for the feedback!

Absolutely agreed. This is on my priority list and there is already an open issue which is tracked here: https://github.com/sharkdp/insect/issues/37

reply

[–] mjn link

This is pretty slick, and I think very useful as-is.

But, while we're all posting wishlists, one thing that'd be nice is if it simplified unnecessarily complex compound units in the result. In the simplest case, it's able to do this, canceling out literally identical units that appear in both a numerator and denominator:

    > 2m/s * 2s
4m

Obviously that is a better result than this hypothetical example would be:

    > 2m/s * 2s
4 m·s/s

But if you use two different units of time, you get essentially a result like that worse one:

    > 2m/s * 2min
4m·min/s

The unit m·min/s is not exactly wrong as a result here, but is unwieldy and a bit unusual as a unit of length. Since a "min/s" is just a scalar quantity, the scalar 60 (1 min/s = 60 s/s = 60), this simplifies to 240m.

You do get that result if you explicitly ask for it,

    > 2m/s * 2min -> m
240m

But it'd be convenient to automatically get these kinds of simplifications, especially when dealing with more complex expressions.

reply

[–] Moter8 link

OT: The angled-brackets are getting interpreted as a part of the URL - both links couldn't be found because of it.

reply

[–] msutherl link
[–] msutherl link

Since Numi <https://numi.io/> has become slow to launch – and I find Soulver <http://www.acqualia.com/soulver/> overkill for quick calculations – I've been looking for a replacement. Here's how to set insect up to run "as" a Mac app.

https://gist.github.com/msutherl/b2ab6d5ae7454ea1a987ee85385...

reply

[–] sharkdp link

Thank you for the feedback. You can use ans to refer to the last result:

  > 5+20
25
> ans+10
35

reply

[–] cjwoodall link

Python and a few other REPLs seem to use _ to capture the previous result. Could be a useful shorthand (not to complicated your design at all)

reply

[–] socialist_coder link

That should be in the docs!

reply

[–] sharkdp link

Done, thanks!

reply

[–] socialist_coder link

I wish it automatically captured the last result and let you easily use it in your next input. The current command line calculator I'm using also lacks this.

> 5+20

> = 25

> +10

> = 35

reply

[–] Nadya link

I'd argue they can be easy to type on most keyboards - just that most people do not enable the functionality and it usually is not enabled-by-default. So not "hard" but "atypical".

On Linux, set up a Compose key[0]. That makes ° become Compose o o. If you're on Windows, a useful thing to do is enable the US-International keyboard so that you can more easily type characters with accents, so you can type Pokémon properly. US-International also respects the AltGR/Right alt to compose many characters [1]. For example, I can type ² by pressing AltGr+2 which really is quite easy. I can also type ° by pressing AltGr+Shift+;

reply

[–] yorwba link

I have a German keyboard, which has keys for °,² and ³. I really liked that when I was typing my math homework in high school. It's not really ergonomic for programming though, what with {[]} not being easily reachable. So now I have my keyboard permanently set to US layout, frustrating anyone who expects the key labels to make sense.

reply

[–] kps link

You just need a better layout.

However, everything the examples inspired me to try fails. 2² works but 2⁴ fails. 30° works but 30°25′8″ fails. 10×3÷4 fails. ‘pi’ and ‘hbar’ are predefined but ‘π’ and ‘ℏ’ aren't.

reply

[–] sharkdp link

Author here, thank you for the feedback! I will try to add these. Tracked here: https://github.com/sharkdp/insect/issues/44

reply

[–] sharkdp link

Thank you for the feedback! I have a german keyboard and haven't really considered this. I will try to improve the examples.

Edit: should be fixed now.

reply

[–] carreau link

the way some other repl improve this is by allowing to tab complete form latex definition. For EG: \habar<tab>, \pi<tab> or 8^2<tab> will expand to what you expect. This also allows for combining like F\vec<tab> of \theta<tab>\dot<tab>

reply

[–] anotheryou link

You can also write ^2 instead of ² and "degrees". But yea, a bit weird as an example.

reply

[–] dagw link

"deg" and "rad" seems to work as well so you don't have to type "degrees" and "radians"

reply

[–] tgb link

Seems very nice. It's a little odd that the examples include characters that are hard to type on most keyboards.

reply

[–] kccqzy link

Not to be snarky, but these days Wolfram Mathematica has spoiled me so much that I use it for even simple computations like the ones is meant for. And I almost always already have it open and I don't need to wait for anything to load.

    >  1920/16*9
1080
>  Sin[30 Degree]
1/2
>  Quantity[2, "Minutes"] + Quantity[30, "Seconds"]
Quantity[150, "Seconds"]
>  UnitConvert[Quantity[6, "Megabits"/"Seconds"] *Quantity[1.5, "Hours"], "Gigabits"]
Quantity[32.4, "Gigabits"]
>  r = Quantity[80, "Centimeters"]
Quantity[80, "Centimeters"]
>  UnitConvert[Pi r^2, ("Meters")^2]
Quantity[(16 \[Pi])/25, ("Meters")^2]
>  UnitConvert[Quantity[40000., "Kilometers"/"SpeedOfLight"], "Milliseconds"]
Quantity[133.426, "Milliseconds"]

It's more verbose to type out the units unless you use the integrated WolframAlpha query with Control-Equal.

reply

[–] azag0 link

Would you expect a complex number as an output? I wouldn't, if someone didn't tell me that it supported complex numbers.

reply

[–] jhlgkhkhil link

From a scientific calculator I would definitely expect complex numbers.

reply

[–] Grue3 link

Well, Emacs Calc does (as well as pretty much everything else).

reply

[–] JadeNB link

Beyond getting a complex number as output: which complex number? (For example, is i or -i the correct answer to sqrt(-1)? If that seems too easy, how about the correct answer to sqrt(-i)?) It would be interesting to see a calculator that handled multi-valued functions properly, but I think that would require some major UI (and possibly even theoretical) advances in order to degenerate gracefully to the single-valued case.

reply

[–] undefined link
[deleted]

reply

[–] sharkdp link

Thank you for the feedback. I'm going to work on this. It is already addressed here: https://github.com/sharkdp/insect/issues/30

reply

[–] tempodox link

  > ln(-1)
NaN
> sqrt(-1)
NaN

Hmmm...

reply

[–] sharkdp link

Thank you for the feedback!

This is not really a bug, but I agree that it looks quite weird right now. Explanation in this comment: https://news.ycombinator.com/item?id=13918393

reply

[–] vmarsy link

this is pretty cool,

    > sqrt(2)
1.41421

> sqrt(2)-1.41421
0.00000356237

> 1.00000356237 + 0.0000001
1


What are the rules you apply when truncating results? number of digits displayed?

    > 3e6 + 0.1
3000000
> 3e7 + 1
30000001
> 3e7 + 1.1
30000000
> 3e7 + 42.9
30000000

There might be a bug, 42.9 < 1 ?

reply

[–] sharkdp link

Thank you for the feedback!

Ctrl-L is used to clear the screen (same as in terminals, apparently it does not work for you?), but I agree... I also use Ctrl-L to change the URL. I'll see if I can change it (this is not really part of insect, but jquery.terminal).

reply

[–] xixi77 link

You are welcome! :)

Just to clarify: Ctrl-L does clear the screen -- this would have been a problem on Windows, but does not bother me on a Mac; on the other hand, Cmd-L (which is the Mac shortcut for the URL) simply prints an "l".

reply

[–] sharkdp link

I see, thanks for the clarification

reply

[–] Stratoscope link

While you're looking, on Windows, Alt+D also normally goes to the address bar in all browsers, but it gets taken over too.

(And I agree this is very cool, especially the way it handles physical units.)

reply

[–] undefined link
[deleted]

reply

[–] xixi77 link

This is neat!

One small annoyance is that it captures common browser shortcuts: e.g. Cmd-L on Mac (iirc Ctrl-L on Win/Linux) is a shortcut for the URL which is what I usually use when I want to go to another page. In insect, it just prints an "l" on screen, so I need to use the mouse to navigate elsewhere.

reply

[–] 32bitkid link

I've used Calca[0] for a while now; and it computes pretty much anything I throw at it. And while its paradigm is nice for a lot of things (a markdown editor that can also do math), I would love a REPL-style interface to it, for quick commandline calculations, so maybe this will fill that void. However, my initial reaction is that its different enough to make it not worth my while. But it's always good to see other products/tools in the same space.

Oddly enough, the reason I eventually stumbled Calca was trying to find a replacement for qalculate[1].

reply

[–] sharkdp link

There is: Currently, "b", "byte" and "bytes" is for bytes and "bit", "bits" is for bits.

reply

[–] lend000 link

This is cool -- is there a distinction between Bytes and bits? That would be useful for performance calculations. Right now, it seems like lower case 'b' is used for bytes and there is no support for bits.

reply

[–] WhitneyLand link

It would be fun to wrap it in a mobile app and customize it for Siri. You could probably generate some decent input speed considering a phone doesn't have a physical keyboard.

Anyway, nice project.

reply

[–] sharkdp link

> It seems as though the "h/s" should be resolved and that the result should instead be "4.05Gb"

Yes, thank you. This is already tracked here:

https://github.com/sharkdp/insect/issues/37

> It would also be nice if "month" and "year" were added. WolframAlpha uses "30 days 10 hours" for a month and 365 days for a year.

I thought about it and didn't add it at first, due to the ambiguity. But I guess these values seem like reasonable defaults.

reply

[–] pveierland link

Nice tool!

  > 6Mbit/s * 1.5h
9Mbit·h/s

It seems as though the "h/s" should be resolved and that the result should instead be "4.05Gb", without needing to explicitly specify that the resulting unit should be Gb:

  > 6Mbit/s * 1.5h -> Gb
4.05Gb

It would also be nice if "month" and "year" were added. WolframAlpha uses "30 days 10 hours" for a month and 365 days for a year.

reply

[–] srean link

You are probably familiar with it already, but in case some readers are not, bc is a nice traditional tool for such things.

https://en.wikipedia.org/wiki/Bc_(programming_language)

reply

[–] popinman322 link

I used to use Lua for quick calculations, but I've recently started using R because of operator vectorization.

For conversions, why use GNU Units over, say, Google in your browser? I find that most of my unit conversions happen in my browser, while I'm online. Anecdotal evidence, obviously, but is this not the case for others? Where do most people use unit conversions?

I'm also not an engineer, so I can't take that into account from experience alone. Wouldn't your tooling provide automated conversions into "correct" units?

reply

[–] tombert link

Oh, I just use Units because I'm used to it, and it has always done the job well. I also like that it's self-contained on my computer, instead of requiring a dependency on the outside world.

reply

[–] niceperson link

You can use GHCi, too.

reply

[–] tombert link

This is quite neat. I tend to just fire up the Python or GNU Units whenever I need some quick math, but it's nice to have something rather consolidated.

reply

[–] chewmieser link

Soulver is also similar and has been around for longer, although it's paid: http://www.acqualia.com/soulver/

reply

[–] jasikpark link

There's a similar MacOS app called Numi that's a bit more polished.

https://numi.io

reply

[–] sharkdp link

When I wrote that, I thought of wolfram alpha....

reply

[–] wtallis link

It seems strange to market a scientific calculator as "fast" when processing power hasn't been a limitation since the 1980s. The way to make a scientific calculator faster in a meaningful way is to make the user interface more efficient. Insect doesn't appear to have any innovations in that field.

reply

[–] eggy link

I use Frink for pretty much of this. I keep it open on my desktop and do calcs like:

250 lbf * 1 m/s -> kW

You can put hp or other desired units you require in the answer. It will hint on balancing the equation to make the units physically similar.

  [1]  https://frinklang.org

reply

[–] dallamaneni link

May also be worth looking at Wolfram open cloud: https://lab.open.wolframcloud.com/objects/wpl/GetStarted.nb

reply

[–] sharkdp link

Thank you for the feedback! I will try to fix this.

reply

[–] madcaptenor link

Notice the following:

  > sin(pi)

-3.73566e-20

> sin(2*pi)

7.47132e-20

> sin(3*pi)

-1.1207e-19

> sin(4*pi)

1.49426e-19

So

  abs(sin(n*pi))

is proportional to n, and

  sin(n*pi)

alternates in sign. This is because your "pi" is really a floating-point number which is slightly more than pi...

Is there a way around this without doing all computation symbolically?

reply

[–] sharkdp link

You are absolutely right. I am afraid there is no good solution for the problem except for performing symbolic calculations or simplifications.

A hacky solution could be to round the output of sin(x) to a given internal precision. This would only hide the real internal numerical problem, though.

It seems that other calculators suffer from the same issue: https://www.google.de/search?q=sin(1e10*pi)

For now, I have increased the internal precision to 30 significant digits and updated the value of Pi to be more precise than that. Of course, this doesn't really solve the problem... just shifts it by a few orders of magnitude :-)

Edit: Also, note that everything is fine if the answer is not zero (due to the rounding in the output):

  > sin(pi)+1
1

reply

[–] undefined link
[deleted]

reply

[–] otnaktut link

  > sin(pi)
-3.73566e-20
Needs some more work...

reply

[–] partycoder link

Seems very similar to speedcrunch (desktop application)

http://speedcrunch.org/

reply

[–] failrate link

I wish it was a bit more usable on my phone, where I would most likely find use for an interface like this.

reply

[–] blauditore link

Hm, it wraps weirdly (mid-word) on narrow screens...

reply

[–] sharkdp link

The output is currently rounded to six significant digits. In this case, the result is 1,000004.., which is rounded to 1,00000 and displayed as 1. I'm not sure what the best default behaviour would be. Typically, I would say that six sign. digits are more than enough for most applications..

reply

[–] tata12345 link

It's great that you use significant digits, but then you have to be explicit about it, and display exactly that many digits, in this case all the zeros (1,00000).

> I would say that six sign. digits are more than enough for most applications

A better solution would be to not use a fixed number of significant digits, but to display the result with the precision of the least precise number the user entered. If you could follow the propagation of uncertainty through the calculations, that would be even better.

https://en.wikipedia.org/wiki/Propagation_of_uncertainty

PS: Great job anyway, bookmarked, thanks!

reply

[–] sharkdp link

Thank you for the feedback!

> It's great that you use significant digits, but then you have to be explicit about it, and display exactly that many digits, in this case all the zeros (1,00000).

Yes, I completely agree from a statistics/physics viewpoint. The reason I display it as 1 right now is that I only have a fixed number of sign. digits (and not the sophisticated solution that you propose - which would be great!). If I always displayed all six digits, one would get 3 - 2 = 1.00000...

> A better solution would be to not use a fixed number of significant digits, but to display the result with the precision of the least precise number the user entered. If you could follow the propagation of uncertainty through the calculations, that would be even better.

That would be fantastic. I'll look into it.

> PS: Great job anyway, bookmarked, thanks!

I'm glad you like it!

reply

[–] wmblaettler link

> 1/0.999996

1

reply

[–] zeropoint46 link

nautical miles / knots would be useful :)

reply

[–] wiz21c link

I find it funny that nowadays one seems to need 30 or 40 routers, a few hundred kilometers of cable, some power source, 43 level of abstraction, 30 maintenance engineers around the globe to, well, compute 10 + 5

reply

[–] anamexis link

There's a certain irony in this rant coming from 'dongslol'.

reply

[–] dongslol link

Well, loldongs was taken!

reply

[–] noxToken link

I agree with you in a sense. Insect is a repl for a scientific calculator. It's hosted on shark.fish. None of those lend indication that it's a repl or used for scientific calculation. That's fine, but neither of them are memorable in their own right if someone wanted to return to it without a bookmark. I don't expect Insect to become a ubiquitous name for college students needing a scientific calculator on the go, but it's a trend/fad/thing that happens with other products who want to break into a certain namespace.

reply

[–] dongslol link
[–] dongslol link

As somebody who thinks messaging is everything, I must protest this name as bad marketing surrounding a potentially good product. Insects evoke in humans a visceral feeling of disgust and sickness. If my work tools were ever being audited I would not be able to explain to my boss why there I am employing an "insect" in my computer.

First impressions are everything. Please see in "The Psychology of Human Misjudgment" the excellent description of humans' "Influence-from-Mere-Association Tendency." The technical merits of a product will not matter if people can't get past their initial feelings. This is highly inconsiderate.

Until the name is swapped out for a more sensible one, I will not be downloading this software.

reply