NumCalc.com The Scientific Web Calculator 
 Help: Tutorial Reference  

NumCalc TutorialNumCalc is a lightweight and easy to use scientific calculator based on QuickJS. It has the following features:
Basic UseYou can type:2*(1+3)
which yields:
8
_ is a variable containing the last result:
3*_
yields:
24
Fractions: NumCalc tries to give exact results with fractions: 1/3+1/2
which yields:
5/6
fractions and integers are not limited in size (except by the memory
and the time you want to spent waiting for the result !). For
example:
2^256
yields the exact value of 2 to the power of 256.
Floating point numbers: You can still get the approximate floating point result by enabling the numeric mode, by using a decimal point in your input or by using the Float() function: 1/3+1/7.0
which yields:
0.47619047619047619047619047619047617
The floating point numbers are internally represented in base 2 with
the IEEE 754 semantics. The internal precision (=number of mantissa
bits) can be changed with the \p (in bits)
or \digits (in decimal digits):
\p
FP precision=113 bits (~34 digits), exponent size=15 bits
\p 192
1/7.0
0.14285714285714285714285714285714285714285714285714285714287
Shortcuts are available for common IEEE 754 floating point
number sizes: \p f64 is the same as \p 53 11.
Functions: all the usual mathematical functions are available such as: sqrt (square root), sin, cos, tab, log (logarithm in base e), exp, ... sin(PI/8)
0.3826834323650897717284599840303989
Variables: You can store your results in variables and reuse them in the following expressions: a=sin(PI/8)
b=sqrt(a)
Multiple expressions: You can type several expressions on the same line by separating them with a semicolon. a=1+3;b=a^2+1
Binary arithmetic: Use the 0x prefix to enter hexadecimal numbers (e.g. 0x1a). The 0b prefix is used for binary numbers. The output radix can be changed with the \x (hexadecimal) and \d (decimal) directives. The calculator supports all the standard Javascript bitwise logical and shift operators. The notable exception is the exclusive or which is implemented with the ^^ operator because the ^ binary operator is reserved for the power operator.
All binary arithmetic functions assume that integers are
represented in two's complement notation. Hence a negative number can
be seen as having an infinite number of '1' to the left. Advanced UseYou can stop reading this tutorial at this point if you don't intend to deal with more advanced mathematical objectsComplex numbers: use the constant I to enter complex numbers: (1+2*I)*(2+3*I)
Most predefined functions deal with complex numbers:
exp(I*PI)
Polynomials: use the constant X to enter polynomials. Polynomials are represented internally as an array of their coefficient, so the actual variable used to represent them does not matter. In the calculator, the X variable is used by convention. (1+X)^3
X^3+3*X^2+3*X+1
You can evaluate a polynomial at one point by using the apply method:
p=(1+X)^3;p.apply(1/2)
apply is also useful to substitute the X variable with another polynomial.A polynomial complex root finder based on the Laguerre's method is also included: polroots(X^31)
Rational fonctions: if you divide two polynomials you get a rational fonction and they can be manipulated as objects too: deriv(1/(1+X)+2/(2+X)+3/(3+X))
gets the derivative of the rational function. Note that integration of rational fonctions is not supported.
Taylor series: Taylor series are created with the O function. Taylor series can be seen as polynomials where all the terms of degrees >= O(X^n) are thrown away. To be more precise, the calculator handles Laurent series as well. It means that the exponents can be negative too. (1+X+O(X^3))^(1/3)
%1 = 1+1/3*X1/9*X^2+O(X^3)
Computes the order 2 taylor expansion of (1+x)^(1/3). The calculator also knows the Taylor expansion of most usual functions:
sin(X+O(X^4))
%2 = X1/6*X^3+O(X^4)
Linear algebra: Vectors and matrixes are supported. Example: a=[[1,2,3],[2,3,4],[5,6,8]]
Compute its determinant:
det(a)
Inverse it:
inverse(a)
The functions rank, ker, charpoly and eigenvals yield respectively the rank, kernel, characteric polynomial and eigen values of a matrix.
Vectors are also supported: v=[1,2,3]
When dealing with matrix multiplication, they are considered as column vectors, e.g:
a*v
[14, 20, 41]
dp(x,y) does the dot product of vectors. cp(x,y) does the 3 dimensional cross product of vectors. Most operations defined on numbers also work on vectors and matrixes componentwise.
Primes: isprime(n) and nextprime(n) test if a number is prime using the Miller Rabin probabilistic test. factor(n) factorize a number using trial divisions. Modulo arithmetic: invmod(a,m) returns the inverse of a modulo m. pmod(a,b,m) compute a^b modulo m with less computational resources than doing a^b%m. It also works with polynomials. Mod(a, n) represents the residue of a modulo the integer n. It supports the usual operators: 1/Mod(3,17)^11+2
yields:
Mod(9,17)
Polynomial modulo P: PolyMod works the same way as Mod but with polynomials: 1/PolyMod(X,X^2+1)
yields:
PolyMod(X,X^2+1)
CreditsNumCalc borrows many ideas from PARI/GP and calc.It uses the QuickJS Javascript engine. NumCalc ReferenceJavascript supportNumcalc relies on a superset of Javascript. The main difference with Javascript are:
DirectivesDirectives change the state of the command line user interface. They are preceeded by the antislash character.
Global definitionsArithmetic
Bit Manipulation
Transcendental
Linear Algebra, Matrixes
Polynomial, Rational functions, Power series
Object propertiesInteger
Float
Fraction instances
Complex instances
Mod instances
RationalFunction instances
PolyMod instances
