A high precision scientific calculator with full support for physical units.
Try the web version here: https://insect.sh
Evaluate mathematical expressions:
1920/16*9
2^32
sqrt(1.4^2 + 1.5^2) * cos(pi/3)^2
Operators: addition (+
), subtraction (-
), multiplication
(*
, ·
, ×
), division (/
, ÷
, per
), exponentiation
(^
, **
). Full list: see Reference below.
Mathematical functions: abs
, acos
, acosh
, asin
,
asinh
, atan
, atan2
, atanh
, ceil
, cos
, cosh
, exp
,
floor
, fromCelsius
, fromFahrenheit
, gamma
, ln
, log
,
log10
, maximum
, minimum
, mean
, round
, sin
, sinh
,
sqrt
, tan
, tanh
, toCelsius
, toFahrenheit
.
High-precision numeric type with 30 significant digits that can handle very large (or small) exponents like 10^(10^10).
Exponential notation: 6.022e23
.
Physical units: parsing and handling, including metric prefixes:
2 min + 30 s
40 kg * 9.8 m/s^2 * 150 cm
sin(30°)
Supported units: see Reference section below.
Implicit conversions: 15 km/h * 30 min
evaluates to
7.5 km
.
Useful error messages:
> 2 watts + 4 newton meter
Conversion error:
Cannot convert unit N·m (base units: kg·m²·s⁻²)
to unit W (base units: kg·m²·s⁻³)
Explicit unit conversions: the ->
conversion operator
(aliases: →
, ➞
, to
):
60 mph -> m/s
500 km/day -> km/h
1 mrad -> degree
52 weeks -> days
5 in + 2 ft -> cm
atan(30 cm / 2 m) -> degree
6 Mbit/s * 1.5 h -> GB
Variable assignments:
Example: mass of the earth
r = 6000km
vol = 4/3 * pi * r^3
density = 5 g/cm^3
vol * density -> kg
Example: oscillation period of a pendulum
len = 20 cm
2pi*sqrt(len/g0) -> ms
Predefined constants (type list
to see them all): speed of
light (c
), Planck's constant (h_bar
), electron mass
(electronMass
), elementary charge (elementaryCharge
),
magnetic constant (µ0
), electric constant (eps0
), Bohr
magneton (µ_B
), Avogadro's constant (N_A
), Boltzmann
constant (k_B
), gravitational acceleration (g0
), ideal gas
constant (R
), ...
Last result: you can use ans
(answer) to refer to the
result of the last calculation.
User-defined functions:
Example: kinetic energy
kineticEnergy(mass, speed) = 0.5 * mass * speed^2 -> kJ
kineticEnergy(800 kg, 120 km/h)
Example: barometric formula
P0 = 1 atm
T0 = fromCelsius(15)
tempGradient = 0.65 K / 100 m
pressure(height) = P0 * (1 - tempGradient * height / T0)^5.255 -> hPa
pressure(1500 m)
Sums and products:
Syntax:
sum(<expression>, <index-variable>, <from>, <to>)
product(<expression>, <index-variable>, <from>, <to>)
Examples:
# sum of the first ten squares
sum(k^2, k, 1, 10)
# the factorial of n as the product 1 × 2 × ... × n
myFactorial(n) = product(k, k, 1, n)
Unicode support:
λ = 2 × 300 µm
ν = c/λ → GHz
And more: tab completion, command history (arrow keys,
Ctrl
+R
), pretty printing, syntax highlighting, ...
Operators (ordered by precedence: high to low)
Operator | Syntax |
---|---|
factorial | ! |
square, cube, ... |
² , ³ , ⁻¹ , ... |
exponentiation |
^ , **
|
multiplication (implicit) | whitespace |
modulo | % |
division | per |
division |
/ , ÷
|
multiplication (explicit) |
* , · , ×
|
subtraction | - |
addition | + |
unit conversion |
-> , → , ➞ , to
|
assignment | = |
Note that implicit multiplication has a higher precedence than
division, i.e. 50 cm / 2 m
will be parsed as 50 cm / (2 m)
.
Commands
Command | Syntax |
---|---|
help text |
help , ?
|
list of variables |
list , ls , ll
|
reset environment | reset |
clear screen |
clear , cls
|
copy result to clipboard |
copy , cp
|
quit (CLI) |
quit , exit
|
Supported units (remember that you can use tab completion).
All SI-accepted units support metric prefixes. In addition, binary
prefixes (MiB
,
GiB
, ...) are also supported.
Unit | Syntax |
---|---|
Ampere |
amperes , ampere , A
|
Ångström |
angstrom , Å
|
Astronomical unit |
AU , au , astronomicalunits , astronomicalunit
|
Atmosphere | atm |
Bar | bar |
Barn | barn |
Becquerel |
becquerel , Bq
|
Bel | bel |
Bit |
bits , bit
|
Bits per second | bps |
British thermal unit | BTU |
Byte |
Bytes , bytes , Byte , byte , B , Octets , octets , Octet , octet
|
Calorie |
calories , calorie , cal
|
Candela |
candela , cd
|
Coulomb |
coulomb , C
|
Cup |
cups , cup
|
DPI | dpi |
Day |
days , day , d
|
Degree |
degrees , degree , deg , °
|
Dot |
dots , dot
|
Electronvolt |
electronvolt , eV
|
Euro |
euros , euro , EUR , €
|
Farad |
farad , F
|
Fluid ounce |
fluidounces , fluidounce , floz
|
Foot |
feet , foot , ft
|
Fortnight |
fortnights , fortnight
|
Frame |
frames , frame
|
Frames per second | fps |
Furlong |
furlongs , furlong
|
Gallon |
gallons , gallon , gal
|
Gauss | gauss |
Gram |
grams , gram , grammes , gramme , g
|
Gray |
gray , Gy
|
Hectare |
hectare , ha
|
Henry |
henrys , henries , henry , H
|
Hertz |
hertz , Hz
|
Hogshead |
hogsheads , hogshead
|
Hour |
hours , hour , h
|
Inch |
inches , inch , in
|
Joule |
joules , joule , J
|
Katal |
katal , kat
|
Kelvin |
kelvin , K
|
Light-year |
lightyears , lightyear , ly
|
Liter |
liters , liter , litres , litre , L , l
|
Lumen |
lumen , lm
|
Lux |
lux , lx
|
Meter |
meters , meter , metres , metre , m
|
Mile |
miles , mile
|
Miles per hour | mph |
Millimeter of mercury | mmHg |
Minute |
minutes , minute , min
|
Mole |
mole , mol
|
Month |
months , month
|
Newton |
newton , N
|
Ohm |
ohms , ohm , Ω
|
Ounce |
ounces , ounce , oz
|
PPI | ppi |
Parsec |
parsecs , parsec , pc
|
Parts-per-million | ppm |
Parts-per-billion | ppb |
Parts-per-trillion | ppt |
Parts-per-quadrillion | ppq |
Pascal |
pascal , Pa
|
Percent |
percent , pct
|
Person |
persons , person , people
|
Piece |
pieces , piece
|
Pint |
pints , pint
|
Pixel |
pixels , pixel , px
|
Pound-force |
pound_force , lbf
|
Pound |
pounds , pound , lb
|
Psi | psi |
RPM |
RPM , rpm
|
Radian |
radians , radian , rad
|
Rod |
rods , rod
|
Second |
seconds , second , sec , s
|
Siemens |
siemens , S
|
Sievert |
sievert , Sv
|
Tablespoon |
tablespoons , tablespoon , tbsp
|
Teaspoon |
teaspoons , teaspoon , tsp
|
Tesla |
tesla , T
|
Thou |
thou , mils , mil
|
Tonne |
tonnes , tonne , tons , ton , t
|
US Dollar |
dollars , dollar , USD , $
|
Volt |
volts , volt , V
|
Watt-hour | Wh |
Watt |
watts , watt , W
|
Weber |
weber , Wb
|
Week |
weeks , week
|
Yard |
yards , yard , yd
|
Year |
years , year
|
Reasons to use Insect
Reasons to choose an alternative
Why are Celsius and Fahrenheit not supported?
Compared to the SI unit Kelvin and in contrast to all other units, Celsius and Fahrenheit require an additive offset when converting into and from other temperature units. This additive offset leads to all kinds of ambiguities when performing calculations in these units. Adding two temperatures in Celsius, for example, is only meaningful if one of them is seen as an offset value (rather than an absolute temperature). Insect is primarily a scientific calculator (as opposed to a unit conversion tool) and therefore focuses on getting physical calculations right.
Even though °C and °F are not supported as built-in units, there are helper functions to convert to and from Celsius (and Fahrenheit):
fromCelsius
takes a scalar value that represents a
temperature in Celsius and returns a corresponding temperature
in Kelvin:
> fromCelsius(0)
= 273.15 K
> k_B * fromCelsius(23) to meV
= 25.5202 meV
toCelsius
takes a temperature in Kelvin and returns a
scalar value that represents the corresponding temperature
in Celsius:
> toCelsius(70 K)
= -203.15
> toCelsius(25 meV / k_B)
= 16.963
Why is 1/2 x
parsed as 1/(2x)
?
Implicit multiplication (without an explicit multiplication sign)
has a higher precedence than division (see operator precedence
rules). This is by design, in order to parse inputs
like 50 cm / 2 m
as (50 cm) / (2 m)
. If you meant ½ · x, write
1/2 * x
.
What is the internal numerical precision?
By default, Insect shows 6 significant digits in the result of the calculation. However, the internal numerical precision is much higher (30 digits).
How does the conversion operator work?
The conversion operator ->
attempts to convert the physical
quantity on its left hand side to the unit of the expression on
its right hand side. This means that you can write an arbitrary
expression on the right hand side (but only the unit part will be
extracted). For example:
# simple unit conversion:
> 120 km/h -> mph
= 74.5645 mi/h
# expression on the right hand side:
> 120 m^3 -> km * m^2
= 0.12 m²·km
# convert x1 to the same unit as x2:
> x1 = 50 km / h
> x2 = 3 m/s -> x1
x2 = 10.8 km/h
What is the relation between the units RPM
, rad/s
, deg/s
and
Hz
?
The unit
RPM
(revolutions per minute) is defined via 1 RPM = 1 / minute
where
the 1
on the right hand side symbolizes "1 revolution".
As the base unit is the same (1 / second
), RPM
can be converted
to rad / s
, deg / s
or Hz
. Note, however, that 1 RPM
does
not equal 2π rad / min
or 360° / min
or 1 Hz
, as some might
expect. If you interested in computing the traversed angle of
something that rotates with a given number of revolutions per
minute, you need to multiply by 2π rad
or 360 °
because:
1 RPM · (360°/revolution) = (1 revolution / minute) · (360° / revolution) = 360° / minute
In addition to the web interface, there is also a command line version which can by installed via npm:
npm install -g insect
Note that this might fail if you run it with sudo
. Instead, set up a
prefix
directory
and call npm install
as a user.
If you prefer not to install nodejs and npm, you can use one of the standalone binaries on the release page.
For Arch Linux, there is a package on AUR:
yaourt -S insect
On Fedora 28+, you can install insect
from the official sources:
sudo dnf install insect
For Fedora versions 26 and 27, you need to enable this copr repository:
sudo dnf copr enable fnux/insect
For macOS, there is a Homebrew package:
brew install insect
For Android, install Termux from Google Play or F-Droid.
Install nodejs in Termux and then install insect
.
pkg install nodejs-lts
npm install -g insect
Insect is written in PureScript (see Getting Started guide). You can install all dependencies and build the whole project by running:
npm install
npm start
Open web/index.html in your browser.
Insect comes with a comprehensive set of unit tests. You can run them by calling
npm test