I created a web-calculator with support for physical units

In summary, David, a theoretical physicist from Stuttgart, Germany, has developed an open source application called Insect, a high-precision scientific calculator with full support for physical units. It is available in web and terminal versions, with full documentation and source code on GitHub. David is seeking feedback on the project and has no plans for personal gain. Some users have suggested adding support for different unit systems and a pool of common constants. David is open to suggestions and improvements for the project.
  • #1
sharkdp
Hi!

My name is David. I'm a theoretical physicist from Stuttgart, Germany. Over the past months I have been developing an open source application called Insect, which I hope would be of interest to some of you. Insect is a high-precision scientific calculator that comes with full support for physical units. Here's a short demo:

insect-demo.png


You can try the web-version here: https://insect.sh/

The full documentation, the source code and a terminal version are available here: https://github.com/sharkdp/insect

Anyway, I would really love to hear your feedback!Full disclosure: This is my first post on this forum. I was careful to read the Forum Guidelines and I hope that this post does not contradict any of the rules. There is no personal gain for me: Insect is an open-source project and is completely free.
 
  • Like
Likes FactChecker, vanhees71 and Stavros Kiri
Physics news on Phys.org
  • #2
As a particle physicist, I would like to see support for different unit systems, in my case natural units. Converting km to eV^-1 is tedious and error prone. I currently usually use Wolfram Alpha for fast conversions, but there as here you need to get the appropriate factors of c and hbar in there. It would be significantly more convenient to just type 1 km -> eV^-1.
 
  • Like
Likes Stavros Kiri
  • #3
I had problems with 4 km/h * 5h 30m 7s.
 
  • #4
Orodruin said:
As a particle physicist, I would like to see support for different unit systems, in my case natural units.

Thank you for the feedback! A similar request has been discussed here: https://github.com/sharkdp/insect/issues/112
I'd be happy to re-open the ticket to discuss this again.

Orodruin said:
Converting km to eV^-1 is tedious and error prone.

I can understand why it is tedious, but error prone? Using a calculator that understands physical units, there is actually no way you can make an error by inserting factors of h_bar and c (as you would get the result in wrong units):

upload_2017-8-20_17-46-1.png
 
  • #5
sharkdp said:
I can understand why it is tedious, but error prone?
It is error prone when you do it by hand. Using Wolfram Alpha will always get you the right result, but you have to find the correct powers of c and hbar, which is tedious.
 
  • #6
fresh_42 said:
I had problems with 4 km/h * 5h 30m 7s.

Thank you for the feedback! Your input "5h 30m 7s" is currently interpreted as "5 hours × 30 meters × 7 seconds". I'm assuming you want to calculate "4 km/h * (5h + 30min + 7s)" (which would work as input). Unfortunately, there is currently no shorter way to enter times in the HH:MM:SS format - but I'd be happy to discuss possible variants of that. You can define your own functions, so sth. like this could be an option:

Code:
time(x, y, z) = x hours + y minutes + z seconds
4km/h * time(5, 30, 7)
 
  • Like
Likes fresh_42
  • #7
sharkdp said:
I'm a theoretical physicist from Stuttgart, Germany.
sharkdp said:
There is no personal gain for me: Insect is an open-source project and is completely free.
Hmm, uncommon combination. Do you plan to make money at some later stage of the project?
 
  • Like
Likes sharkdp
  • #8
fresh_42 said:
Hmm, uncommon combination. Do you plan to make money at some later stage of the project?

Ouch! :-)

No, I don't have any plans to make money with the project...
(I work as a software developer...)
 
  • #9
Interesting and useful. I like it (first impression).
[And welcome to PF!]
 
  • Like
Likes sharkdp
  • #10
sharkdp said:
Ouch! :-)

No, I don't have any plans to make money with the project...
(I work as a software developer...)
Sorry, couldn't resist. :wink:

Do you have a control sign for constants like ##h,\hbar,N_A,k_B,G## or ##c##? I found this as a major disadvantage on Wolfram as ##h## is automatically interpreted as hour. Would be easier to have a pool of common constants available.
 
  • Like
Likes sharkdp and Stavros Kiri
  • #11
fresh_42 said:
Sorry, couldn't resist. :wink:

Do you have a control sign for constants like ##h,\hbar,N_A,k_B## or ##c##? I found this as a major disadvantage on Wolfram as ##h## is automatically interpreted as hour. Would be easier to have a pool of common constants available.

What do you mean by control sign? A special character that introduces a constant (like $hbar)? No - constants and units currently share the same namespace, so there might be problems like the one you mentioned (hbar is "hector bar" :frown:) - but I like the idea. Insect has a "pretty printer" which prints units in green and constants/variables in orange - so this might help.

For reference, ##h## = PlanckConstant, ##\hbar## = h_bar or ℏ, ##N_A## = N_A, ##k_B## = k_B, ##c## = c, speedOfLight, ##G## = G. You can type "list" to see all constants.
 
  • Like
Likes Stavros Kiri
  • #12
I just thought that $h would be a lot shorter than to type in PlanckConstant. E.g. I use a tiny program to abbreviate LaTeX commands, like Alt+M for ##\text{ \begin{bmatrix}\end{bmatrix}}\,.## Makes life easier. Btw. do you need the distinction between upper and lower case characters? And if so, wouldn't it be natural to write Planckconstant than PlanckConstant - not that it is important.
 
  • Like
Likes sharkdp
  • #13
fresh_42 said:
I just thought that $h would be a lot shorter than to type in PlanckConstant.

True, I'll consider adding this. Thanks!
Note that you can use tab-completion, so "pl<tab>" also works :wink:.

fresh_42 said:
Btw. do you need the distinction between upper and lower case characters?

It's definitely useful. C = Coulomb, c = speed of light. G = gravitational constant, g = gram. H = henry, h = hour. S = Sievert, s = second. T = Tesla, t = ton.

fresh_42 said:
And if so, wouldn't it be natural to write Planckconstant than PlanckConstant - not that it is important.

I probably chose this from a programmer perspective where variable names are usually lowercase (and often Camel case). Note that user-defined variables are supported (simply type "Planckconstant = PlanckConstant"). It's not very practical at the moment because user-sessions can not be stored, yet (I definitely plan to support this).
 
  • #14
Cool stuff.

Regarding the natural units Orodruin brought up, it might be interesting to look into an algorithmic way to do this.
A great starting point is already present as proven by your error message.
E.g. for $$2\mathrm{km}\rightarrow(neV)^{-1}$$ you convert the units on both sides of the arrow to $$[\mathrm{L}]$$ resp. $$[M]^{-1}[L]^{-2}[T]^2$$ (here I used the quantity short-hands M = mass, L = length and T = time)
Next it should be possible to find the conversion factor, although I'm not certain in which way this is done best.

If I find the time I'll try and look into this sometime this week and get back to you.
 
  • Like
Likes sharkdp
  • #15
JorisL said:
Next it should be possible to find the conversion factor, although I'm not certain in which way this is done best.

Yes, it can be posed as a simple linear algebra problem (where different base units represent different dimensions). ##\hbar## with units ##[\hbar] = \text{kg} \cdot \text{m}^2 \cdot \text{s}^{-1}##, for example, is represented as a vector ##(1, 2, -1)^T## in the "(KG, M, S)" space. In this way, it would be easy to solve for the exponents of ##\hbar, c##, etc. [One problem is: there are different sets of natural units].

I really don't want the normal conversion operator "->" to have any "magic" funtionality. This could definitely lead to confusion if random factors of ##\hbar##, etc. are inserted when a user makes an error in asking for a certain conversion (for example).

Coming to think of it, it could be an option to introduce a special conversion operator ("~>" ? :smile:) that would support this. So "2 km ~> neV^-1" would work.
 
  • #16
Hmm, how much time would it take to implement named functions?
Because in this case it could be useful to define a function like PlanckToSI (c=h=g=k_b=k_e=1) or geometrizedToSi (c = G = 1).
Each of them defines the linear algebra problem internally et voila you're done.

I bet it would lead to quite some attention as well.
 
  • #17
JorisL said:
Hmm, how much time would it take to implement named functions?

Named functions are already supported. You can define "f(x, y) = 2*x*y + 3 cos(x/5) sin(y)", for example.

JorisL said:
it could be useful to define a function like PlanckToSI (c=h=g=k_b=k_e=1)

That would be a completely new syntax, but I see your point. Maybe it would be easier to store a few predefined unit-systems and the user could simply type "set natural_units gauss" or something similar.
 
  • #18
This made me think of Mathcad, which automatically converts units and checks equations for compatibility of units. I really liked it for that.
 
  • Like
Likes sharkdp

What inspired you to create a web-calculator with unit support?

I noticed that many online calculators did not include support for physical units, making it difficult for scientists and engineers to perform calculations accurately. I wanted to create a tool that would make it easier for them to work with units while using a calculator.

How accurate are the unit conversions in your web-calculator?

The unit conversions in my web-calculator are based on standard conversion factors and are accurate to the decimal place. However, it is always important to double check your calculations to ensure accuracy.

What sets your web-calculator apart from other online calculators?

The main feature that sets my web-calculator apart is the support for physical units. This allows users to input values with units and receive results in the same unit or a different unit, making it more convenient for scientific calculations.

Can I use your web-calculator for any type of unit conversion?

Yes, my web-calculator supports a wide range of physical units, including length, mass, time, temperature, pressure, and more. If there is a specific unit you would like to see added, please let me know!

Is your web-calculator user-friendly for those without a scientific background?

Yes, my web-calculator is designed to be user-friendly for all types of users, including those without a scientific background. The interface is simple and easy to use, and the unit conversion feature is optional, so users can choose to use it or not.

Similar threads

Replies
9
Views
913
  • New Member Introductions
Replies
2
Views
67
Replies
1
Views
229
Replies
86
Views
4K
Replies
0
Views
411
  • New Member Introductions
Replies
3
Views
56
  • General Discussion
Replies
8
Views
197
  • Programming and Computer Science
Replies
29
Views
5K
  • Introductory Physics Homework Help
Replies
11
Views
791
Back
Top