JavaScript-based Calculator

#6
#5
#4
#3
#2
#1

res

Help

This is a scientific command-oriented calculator working by submitting partially edited formulas to the JavaScript eval() function.

The calculator formulas written in the usual syntax by numbers, operators, elementary functions, and parentheses. A formula, expression, command, or a ;-separated list should be written into the yellowish input area (before button =) and is evaluated by pressing button =. Examples:

a=2+3*7
1/sin(1-a);b=cos(1-a)
The last result is denoted by res or # and also res1 or #1, previous result res2 or #2, etc. (see numbers at right).

In order to simplify entering formulas without pressing SHIFT, the following translations take place:

Examples:
a=2 3 (the same as a=2*3)
a=2'3 (the same as a=2+3)
`+3 (the same as #+3)
In addition, the last expression can be simplified to only +3; use parentheses or a space to type a negative number:
 -5 (number -5)
(-5) (number -5)
-5 (subtract 5 from previous result)

Functions

ln (natural), log (decadic), exp
sin, cos, tan, asin, acos, atan
(in radians),
sqr, cub (square, cube)root),
sqrt, \ (square root), cbrt (cube root),
pow (general power: 2**3=pow(2,3))
abs, Int (Int(2.6)=2, Int(-2.6)=-2)
fac (factorial)
x=1; solve("x*x-2") (optional seed x; solve equation of x)
Note that operator ** is not supported (and ^ means xor). All JavaScript functions like Math.floor(ARG) can be used, too.

Pre-defined constants

Defined or based on CODATA 2014 in SI units

pi Archimedes' constant
deg pi/180 (examples: sin(30 deg), asin(0.5)/deg)
R gas constant
F Faraday charge
NA Avogadro constant
A Debye law constant for water at 25 °C
G gravity constant
Hartree molar atomic energy unit
Eh atomic energy unit
Ry Rydberg constant
alpha fine structure constant
e elementary charge
h Planck constant
k Boltzmann constant
me electron mass
c speed of light
mu0=4e-7*pi permeability of vacuum
eps0=1e7/(c^2*4*pi) permittivity of vacuum
g standard gravity
a0=eps0*h^2/pi/me/e^2 Bohr radius
cal thermochemical calorie
kcal thermochemical kilocalorie
torr torr = mm Hg
TC=273.15 0 °C
pst standard pressure

Versions

This program is © J. Kolafa and can be distributed under the GNU General Public Licence.

tophome