Documentation

This documentation introduces the main features of Calcumber and provides examples, references, and practical usage notes.

See also:

Basic Arithmetic

Type a mathematical expression and Calcumber evaluates it instantly.
Click the table below to open and modify the example in the web app.

3*4 / (2 + 4) 2
2^7 - 1 127
sqrt(3^2 + 4^2) 5

See also: list of defined functions

Variables

Use the special variable ans to refer the result of the previous calculation or define your own variables to store and reuse values.

=== Previous result ===  
2*6 12
ans + 8         # reuse previous result 20
   
=== Store result in named variable ===  
n = 7 7
n * (n-1) / 2   # use variable in formula 21

Some variables representing mathematical constants like pi or physical constants like c (speed of light) are predefined. If you assign a new value to a predefined constant, the original value remains available through a backup variable prefixed with an underscore (_pi, _c, ...).

=== Predefined ===  
pi 3.1415927
e     # Euler's constant 2.7182818
c     # speed of light 2.9979246e8 m/s
g     # standard gravity 9.80665 m/s2
R     # molar gas constant 8.3144626 J/(mol*K)
eps0  # vacuum permittivity 8.8541878e-12 F/m
mu0   # vacuum permeability 1.2566371e-6 N/A2
   
=== Changing Predefined ===  
g = 9.81 m/s^2  # if you prefer this value 9.81 m/s2
_g              # there is a backup 9.80665 m/s2

See also: list of defined constants

Multipliers

Large and small numbers can be entered using standard exponential notation such as 2.5e6 for 2.5 million. An alternative notation is 2.5M: the multiplier letter M directly after the number multiplies the number by 1 million. Multiplier letters such as k, M, G or m, µ (u) can be also be used in place of the decimal point: 2M5 instead of 2.5M or 2500000.

1m 0.001
1k 1000
1M 1e6
   
4700 4700
4.7k 4700
4.7e3 4700
4k7 4700
   
22.5/100 0.225
22.5% 0.225
22%5 0.225

See also: list of multipliers.

Units

Calcumber supports calculations with units and automatic unit conversion:

Adding compatible units:  
5 m + 30 cm + 5 inch 5.427 m
   
Average speed during a car trip:  
57 km / 40 min 1.425 km/min
ans to km/h 85.5 km/h
ans to mph 53.127237 mph
   
Right-angled triangle:  
a = 3 m 3 m
b = 4 m 4 m
c = sqrt(a^2 + b^2) 5 m
   
Water flow rate:  
20 l/min to m3/h 1.2 m3/h

See: list of defined units

Rules for Entering Units

In Calcumber, spaces are significant when working with units. Use spaces to separate numbers, units, and operators, but not within a unit expression.

Use space between number and unit:

5 m   # unit meter 5 m
5m    # multiplier milli 0.005

End unit expressions with a space:

5 m^2     # square metres 5 m2
5 m ^2    # square the value 5 m 25 m2
   
1 m+1 m    # space missing  
1 m + 1 m  # space between 'm' and '+' 2 m
(1 m)^2    # bracket after unit is fine 1 m2

Don't use space within unit expressions:

You defined in some preceeding calculation:  
Mass: m = 5 kg 5 kg
   
Now you calculate torque:  
correct: T = 18 N*m    # unit Newton metre (=J) 18 J
wrong:   T = 18 N * m  # multiply by variable m 90 N*kg

Conversion

For unit conversion, use the keyword to or in.
Use to base or in base to convert to base units.

50 mph to km/h 80.4672 km/h
3 gal in L 11.356235 L
   
Miles per gallon to L/100 km:  
1 / 23 mi/gal 0.043478261 gal/mi
ans to cl/km     # = L/100 km 10.226721 cl/km
   
Weight of US Letter Paper:  
8.5 inch * 11 inch * 80 g/m2 to g 4.8257968 g
   
To base units:  
1 mph to base 0.44704 m/s
10 N to base 10 kg*m/s2

Partial conversion: If the requested target unit does not match the dimension of the input quantity, Calcumber performs a partial conversion and preserves the remaining dimensions. This can reveal interesting physical relationships:

1 W to s    # Power is energy per unit time 1 J/s
1 L to cm   # Volume is length cubed 1000 cm3
1 Pa to J   # Pressure is energy per unit volume 1 J/m3
1 mm to L   # Rainfall depth and volume 1 L/m2

Undefined Units

Units do not need to be predefined. Undefined units can still be used in calculations and may either cancel out or remain in the result.

Using undefined unit 'person':  
water_consumption = 150 L/person/day * 8000 person to m3/h 50 m3/h
   
Using undefined unit 'EUR':  
energy_bill = 0.29 EUR/kWh * 7600 kWh/year 2204 EUR/year

Fluid Properties

Calcumber can calculate thermodynamic fluid properties using the integrated CoolProp library. Load a fluid such as water, air, nitrogen, propane, or a refrigerant and calculate properties like density, enthalpy, entropy, viscosity, thermal conductivity, saturation pressure, and vapor quality.

This makes it possible to include real fluid-property calculations directly in engineering formulas, for example for heat pumps, refrigeration cycles, steam generation, air flows, or hydraulic heating circuits.

load fluid water 1
h(1 bar, 20 °C) 84.006054 kJ/kg
h(4 bar, 160 °C) 2775.1891 kJ/kg
rho(1 bar, 20 °C) 998.20654 kg/m3

See the Fluid Properties documentation for loading fluids, defining thermodynamic states, temperature conversion, two-phase calculations, and larger examples.

Reference

Multipliers

Documentation is work in progress ...

TODO: multipliers describe °, % ° is also missing in Angular units

Constants

Mathermatical Constants

pi    # circle constant 3.1415927
e     # Euler's number 2.7182818
phi   # golden ratio 1.6180340
gamma # Euler-Mascheroni constant 0.57721566
zeta3 # Apéry's constant = ζ(3) 1.2020569

Source: Wikipedia article List of mathematical constants .

Physical Constants

c      # speed of light in vacuum 2.9979246e8 m/s
g      # standard gravity 9.80665 m/s2
G      # Newtonian constant of gravity 6.6743e-11 m3/(kg*s2)
R      # molar gas constant 8.3144626 J/(mol*K)
N_A    # Avogadro constant 6.0221408e23 1/mol
k_B    # Boltzmann constant 1.380649e-23 J/K
h      # Planck constant 6.6260702e-34 J*s
h_bar  # reduced Planck constant (ħ = h / 2π) 1.0545718e-34 J*s
eps0   # vacuum permittivity (electric constant) 8.8541878e-12 F/m
mu0    # vacuum permeability (magnetic constant) 1.2566371e-6 N/A2
Q_e    # elementary charge 1.6021766e-19 C
m_e    # electron mass 9.1093837e-31 kg
m_p    # proton mass 1.6726219e-27 kg
m_n    # neutron mass 1.6749275e-27 kg
alpha  # fine-structure constant 0.0072973526
Ry     # Rydberg constant (energy form) 2.1798724e-18 J
sigma  # Stefan-Boltzmann constant 5.6703744e-8 W/(m2*K4)
b_wien # Wien's displacement constant 0.0028977720 m*K

Source: Wikipedia article List of physical constants .

Modifying and Restoring

Constants are normal variables.  
You may assign new values:  
pi = 3 3
(5 m)^2*pi 75 m2
   
All constants have a backup starting with '_':  
_pi 3.1415927
(5 m)^2*_pi 78.539816 m2
   
Restore:  
pi = _pi 3.1415927

Units

SI Units

Base Units:

1 m   # length, meter 1 m
1 s   # time, second 1 s
1 kg  # mass, kilogram 1 kg
1 A   # electrical current, Ampère 1 A
1 K   # temperature, Kelvin 1 K
1 mol # amount of substance, mole 1 mol
1 cd  # luminous intensity, candela 1 cd

Derived Units:

1 g   to kg       # gram 0.001 kg
1 Hz  to 1/s      # Hertz 1 1/s
1 N   to kg*m/s^2 # Newton 1 kg*m/s2
1 Pa  to N/m2     # Pascal 1 N/m2
1 J   to N*m      # Joule 1 N*m
1 W   to J/s      # Watt 1 J/s
1 C   to A*s      # Coulomb 1 A*s
1 V   to J/C      # Volt 1 J/C
1 Ohm to V/A      # Ohm 1 V/A
1 S   to 1/Ohm    # Siemens 1 1/Ohm
1 F   to C/V      # Farad 1 C/V
1 Wb  to V*s      # Weber 1 V*s
1 T   to V*s/m2   # Tesla 1 V*s/m2
1 H   to V*s/A    # Henry 1 V*s/A
1 lm  to cd*sr    # lumen 1 cd*sr
1 lx  to lm/m2    # lux 1 lm/m2
1 Bq  to 1/s      # Becquerel 1 1/s
1 Gy  to J/kg     # Gray 1 J/kg
1 Sv  to J/kg     # Sievert 1 J/kg
1 kat to mol/s    # katal 1 mol/s

Angular and Scalar Units

Angular units:

1 rad    to 1        # radian 1
1 deg    to 1        # degree 0.017453293
1 deg    to arcmin 60 arcmin
1 arcmin to arcsec 60 arcsec
1 sr   to 1          # steradian 1

Scalar units:

1 %    to 1  # percent 0.01
1 ppm  to 1  # parts per million 1e-6
   
Calculating a percent value:  
4.8 / 6.7 in % 71.641791 %
   
Thermal Expansion:  
CTE = 45 ppm/K 45 ppm/K
l = 1.5 m 1.5 m
ΔT = 70 K 70 K
Δl = CTE * l * ΔT to mm 4.725 mm
l + Δl 1.504725 m

Multiplier Prefixes

Many units support multiplier prefixes. Example using Joule:

1 aJ  to J  # atto 1e-18 J
1 fJ  to J  # femto 1e-15 J
1 pJ  to J  # pico 1e-12 J
1 nJ  to J  # nano 1e-9 J
1 uJ  to J  # micro 1e-6 J
1 µJ  to J  # micro 1e-6 J
1 mJ  to J  # milli 0.001 J
1 cJ  to J  # centi 0.01 J
1 dJ  to J  # deci 0.1 J
1 J 1 J
1 DJ  to J  # deka 10 J
1 hJ  to J  # hecto 100 J
1 kJ  to J  # kilo 1000 J
1 MJ  to J  # mega 1e6 J
1 GJ  to J  # giga 1e9 J
1 TJ  to J  # tera 1e12 J
1 PJ  to J  # peta 1e15 J
1 EJ  to J  # exa 1e18 J

Length

1 inch to m        # inch 0.0254 m
1 in               # 'in' is keyword (alias for to)  
1 mil  to inch     # thousandth of inch 0.001 inch
1 ft   to inch     # foot 12 inch
1 mi   to ft       # mile 5280 ft
1 yd to ft         # yard 3 ft
1 au   to m        # astronomical unit 1.4959787e11 m
1 dioptre in 1/m   # dioptre 1 1/m

Area

1 are to m2  # are 100 m2
1 ac to ft2  # acre 43560 ft2
1 ha to m2   # hectare 10000 m2

Volume

1 L to dm3     # litre 1 dm3
1 l to dm3     # litre 1 dm3
1 gal to L     # US gallon 3.7854118 L
1 gal to qt    # US quart 4 qt
1 qt to pt     # US pint 2 pt
1 gal to floz  # US fluid ounce 128 floz
1 floz to tbsp # tablespoon 2 tbsp
1 floz to tsp  # teaspoon 6 tsp
1 cup to L     # Approx. metric cup 0.24 L

Time

1 min to  s 60 s
1 h to min 60 min
1 d to h 24 h
1 week to d 7 d
1 month to d 30.4375 d
1 year to d 365.25 d
1 year to month 12 month

Aliases: hour, hours, day, days, weeks, a, years, months

Speed

1 mph to km/h   # miles per hour 1.609344 km/h
1 fps to m/s   # foot per second 0.3048 m/s
1 knot to km/h  # nautical mile per hour 1.852 km/h

Mass

1 t    to kg     # ton 1000 kg
1 lb   to kg     # pound (avoirdupois) 0.45359237 kg
1 lb   to oz     # ounce 16 oz
1 st   to lb     # stone 14 lb
1 ton_us to lb   # US ton 2000 lb
1 ton_uk to lb   # UK long ton 2240 lb
1 Da   to kg     # Dalton 1.6605391e-27 kg

Energy:

1 eV to J   # electronvolt 1.6021764e-19 J
1 Wh to J   # Watt hour 3600 J
1 BTU to J  # British thermal unit 1055.0559 J
1 cal to J  # calorie 4.184 J
1 Cal to J  # Used on food labels = 1 kcal 4184 J

Temperature

The following temperature units are defined in Calcumber:

K Kelvin. Base unit for all temperatures.
°C or degC Degree Celsius
°F or degF Degree Fahrenheit
°Ra or degRa Degree Rankine

By default, all temperature values are interpreted as temperature differences. Therefore, converting °C to Kelvin will not add 273.15 K. This behavior prevents interpretation problems in many calculations as shown in the example below:

Expression Result
Mass:           m  = 100 kg 100 kg
Temp. increase: ΔT = 40 °C 40 °C
Spec. heat:     cp = 4182 J/(kg*K) 4182 J/(kg*K)
   
Energy needed:  
m * ΔT * cp  to kWh 4.6466667 kWh

Heating up 100 kg of water by 40°C needs 4.6 kWh. If Calcumber would convert 40°C to 313 K, the result would be 36.4 kWh, which would be the value for heating it up from 0 K to 313 K.

For converting actual temperature values between the scales, use the defined conversion functions as below:

Expression Result
Conversion of temperature differences:  
10 °C  to K 10 K
10 °F  to K 5.5555556 K
   
Conversion of temperature values:  
to_K(10 °C) 283.15 K
to_K(10 °F) 260.92778 K
to_degF(0 °C) 32 °F
to_degC(0 °F) -17.777778 °C
to_degRa(1000 °C) 2291.67 °Ra

Force and Pressure

Force:

1 lbf to N   # pound-force 4.4482216 N

Pressure:

1 bar to Pa 100000 Pa
1 psi to bar  # pounds per square inch 0.068947573 bar
1 atm to bar  # standard atmosphere 1.01325 bar

Functions

Trigonometry

Functions defined: sin, cos, tan, asin, acos, atan sinh, cosh, tanh, asinh, acosh, atanh.

Usage as below:

sin(30°) 0.5
sin(30 deg) 0.5
sin(pi/6) 0.5
   
asin(0.5) 0.52359878
asin(0.5) in ° 30 °
asin(0.5) in deg 30 deg

Exponential Functions and Logarithms

exp(1) 2.7182818
ln(e) 1
exp10(3) 1000
log10(1000) 3
sqrt(25 m2) 5 m

Numerical Functions

abs(-5) 5
abs(-5 m/s) 5 m/s
sign(-7) -1
   
Rounding is applied after conversion to base units:  
ceil(1 km / 3) 334 m
floor(1 km / 3) 333 m
round(1 km / 3) 333 m
   
Use second argument to specify discretisation:  
E = 78 W * 1 year in kWh 683.748 kWh
round(E, 0.1 kWh) 683.7 kWh
floor(E, 0.1 kWh) 683.7 kWh
ceil(E, 0.1 kWh) 683.8 kWh

Combinatorics

fac(4)     # 4! = 1*2*3*4 24
nCr(5,2)   # fac(5) / ( fac(2) * fac(5-2) ) 10
nPr(5,2)   # fac(5) / fac(5-2) 20