1(1)                     insect - scientific calculator                     (1)
2
3
4

NAME

6       insect - interactive scientific calculator
7

SYNOPSIS

9       insect [EXPR]
10

DESCRIPTION

12       insect  is a high-precision scientific calculator with full support for
13       physical units.
14
15       It can be used in interactive mode by simply calling insect.  This mode
16       can  also  be  used to read from a file, by simply piping the file con‐
17       tents via insect < my-calculation.ins.  If you want to evaluate just  a
18       single expression, pass it as an argument: insect '70mph to km/h'.
19
20   Documentation
21       · Evaluate mathematical expressions:
22
23                1920/16*9
24                2^32
25                sqrt(1.4^2 + 1.5^2) * cos(pi/3)^2
26
27         · Operators: addition (+), subtraction (-), multiplication (*, ·, ×),
28           division (/, ÷, per), exponentiation (^, **).  Full list: see  Ref‐
29           erence below.
30
31         · Mathematical  functions:  acos,  acosh,  asin,  asinh, atan, atan2,
32           atanh, ceil, cos, cosh, exp,  floor,  fromCelsius,  fromFahrenheit,
33           gamma,  ln,  log,  log10, round, sin, sinh, sqrt, tan, tanh, toCel‐
34           sius, toFahrenheit.
35
36         · High-precision numeric type with 30  significant  digits  that  can
37           handle very large (or small) exponents like 10^(10^10).
38
39         · Exponential notation: 6.022e23.
40
41       · Physical units: parsing and handling, including metric prefixes:
42
43                2 min + 30 s
44                40 kg * 9.8 m/s^2 * 150 cm
45                sin(30°)
46
47         · Supported units: see Reference section below.
48
49         · Implicit conversions: 15 km/h * 30 min evaluates to 7.5 km.
50
51         · Useful error messages:
52
53                  > 2 watts + 4 newton meter
54
55                  Unification error:
56                    Cannot convert unit N·m (base units: kg·m²·s⁻²)
57                                to unit W (base units: kg·m²·s⁻³)
58
59       · Explicit unit conversions: the -> conversion operator (aliases: →, ➞,
60         to):
61
62                60 mph -> m/s
63                500 km/day -> km/h
64                1 mrad -> degree
65                52 weeks -> days
66                5 in + 2 ft -> cm
67                atan(30 cm / 2 m) -> degree
68                6 Mbit/s * 1.5 h -> GB
69
70       · Variable assignments:
71
72         Example: mass of the earth
73
74                r = 6000km
75                vol = 4/3 * pi * r^3
76                density = 5 g/cm^3
77                vol * density -> kg
78
79         Example: oscillation period of a pendulum
80
81                len = 20 cm
82                2pi*sqrt(len/g0) -> ms
83
84         · Predefined constants (type list to see them all):  speed  of  light
85           (c),  Planck's constant (h_bar), electron mass (electronMass), ele‐
86           mentary charge (elementaryCharge), magnetic constant (µ0), electric
87           constant  (eps0),  Bohr  magneton (µ_B), Avogadro's constant (N_A),
88           Boltzmann constant (k_B), gravitational acceleration (g0), ...
89
90         · Last result: you can use ans (answer) to refer to the result of the
91           last calculation.
92
93       · User-defined functions:
94
95         Example: kinetic energy
96
97                kineticEnergy(mass, speed) = 0.5 * mass * speed^2 -> kJ
98
99                kineticEnergy(800 kg, 120 km/h)
100
101         Example: barometric formula
102
103                P0 = 1 atm
104                T0 = fromCelsius(15)
105                tempGradient = 0.65 K / 100 m
106
107                pressure(height) = P0 * (1 - tempGradient * height / T0)^5.255 -> hPa
108
109                pressure(1500 m)
110
111       · Sums and products:
112
113         Syntax:
114
115                sum(<expression>, <index-variable>, <from>, <to>)
116                product(<expression>, <index-variable>, <from>, <to>)
117
118         Examples:
119
120                # sum of the first ten squares
121                sum(k^2, k, 1, 10)
122
123                # the factorial of n as the product 1 × 2 × ... × n
124                myFactorial(n) = product(k, k, 1, n)
125
126       · Unicode support:
127
128                λ = 2 × 300 µm
129                ν = c/λ → GHz
130
131       · And more: tab completion, command history (arrow keys, Ctrl+R), pret‐
132         ty printing, syntax highlighting, ...
133
134   Reference
135       · Operators (ordered by precedence: high to low)
136
137         Operator                    Syntax
138         ──────────────────────────────────────────
139         factorial                   !
140         square, cube, ...           ², ³, ⁻¹, ...
141         exponentiation              ^, **
142         multiplication (implicit)   whitespace
143         modulo                      %
144         division                    /, ÷, per
145         multiplication (explicit)   *, ·, ×
146         subtraction                 -
147         addition                    +
148         unit conversion             ->, →, ➞, to
149         assignment                  =
150
151         Note that implicit multiplication has a higher precedence than  divi‐
152         sion, i.e.  50 cm / 2 m will be parsed as 50 cm / (2 m).
153
154       · Commands
155
156         Command             Syntax
157         ─────────────────────────────────
158         help text           help, ?
159         list of variables   list, ls, ll
160         reset environment   reset
161         clear screen        clear, cls
162         quit (CLI)          quit, exit
163
164   FAQ
165       · Why are Celsius and Fahrenheit not supported?
166
167         Compared to the SI unit Kelvin (https://en.wikipedia.org/wiki/Kelvin)
168         and in contrast to all other units, Celsius and Fahrenheit require an
169         additive  offset  when  converting  into  and  from other temperature
170         units.  This additive offset leads to all kinds of  ambiguities  when
171         performing  calculations  in these units.  Adding two temperatures in
172         Celsius, for example, is only meaningful if one of them is seen as an
173         offset  value  (rather than an absolute temperature).  Insect is pri‐
174         marily a scientific calculator (as opposed to a unit conversion tool)
175         and therefore focuses on getting physical calculations right.
176
177         Even  though °C and °F are not supported as built-in units, there are
178         helper functions to convert to and from Celsius (and Fahrenheit):
179
180         · fromCelsius takes a scalar value that represents a  temperature  in
181           Celsius and returns a corresponding temperature in Kelvin:
182
183           > fromCelsius(0)
184
185              = 273.15 K
186
187           > k_B * fromCelsius(23) to meV
188
189              = 25.5202 meV
190
191         · toCelsius  takes a temperature in Kelvin and returns a scalar value
192           that represents the corresponding temperature in Celsius:
193
194           > toCelsius(70 K)
195
196              = -203.15
197
198           > toCelsius(25 meV / k_B)
199
200              = 16.963
201
202       · Why is 1/2 x parsed as 1/(2x)?
203
204         Implicit multiplication (without an explicit multiplication sign) has
205         a  higher  precedence  than division (see operator precedence rules).
206         This is by design, in order  to  parse  inputs  like  50 cm / 2 m  as
207         (50 cm) / (2 m).  If you meant ½ · x, write 1/2 * x.
208
209       · What is the internal numerical precision?
210
211         By  default,  Insect  shows 6 significant digits in the result of the
212         calculation.  However, the internal numerical precision is much high‐
213         er (30 digits).
214
215       · How does the conversion operator work?
216
217         The  conversion operator -> attempts to convert the physical quantity
218         on its left hand side to the unit of the expression on its right hand
219         side.   This  means that you can write an arbitrary expression on the
220         right hand side (but only the unit part will be extracted).  For  ex‐
221         ample:
222
223                > x1 = 50 km / h
224
225                > x2 = 3 m/s -> x1
226
227                  x2 = 10.8 km/h
228

AUTHOR

230       Written by David Peter <mail@david-peter.de>.
231

REPORTING BUGS

233       Please report bugs on GitHub: <https://github.com/sharkdp/insect>.
234
236       insect       is       MIT-licensed.        For       details,       see
237       <https://github.com/sharkdp/insect>.
238

SEE ALSO

240       · Full documentation at <https://github.com/sharkdp/insect>.
241
242       · Web-version at <https://insect.sh>.
243
244
245
246                                                                           (1)
Impressum