NumCalc is a lightweight and easy to use scientific calculator. It has
the following features:
described in the paper jsbignum.pdf.
- Arbitrary precision integers and floating point numbers, fractions
- Complex numbers including complex transcendental functions
- Polynomials, rational fonctions and Taylor series
- Linear algebra: matrix inversion, rank, eigen values and kernel extraction.
You can type:
_ is a variable containing the last result:
Fractions: NumCalc tries to give exact results with
fractions and integers are not limited in size (except by the memory
and the time you want to spent waiting for the result !). For
yields the exact value of 2 to the power of 256.
Floating point numbers:
You can still get the
approximate floating point result by using a decimal point in
your input or by using the Float() function:
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):
FP precision=128 bits (~38 digits), exponent size=30 bits
Functions: all the usual mathematical functions are available such as: sqrt (square root), sin, cos, tab, log (logarithm in base e), exp, ...
Constants are referenced by upper case names, e.g. PI for the pi constant. Example:
Variables: You can store your results in variables and reuse them in the following expressions:
Multiple expressions: You can type several expressions on the same line by separating them with a semicolon.
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.
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.
It is possible to toggle between the Math or standard
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.
You can stop reading this tutorial at this point if you don't intend to deal with more advanced mathematical objects
Complex numbers: use the constant I to enter complex numbers:
Most predefined functions deal with complex numbers:
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.
You can evaluate a polynomial at one point by using the apply method:
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:
Rational fonctions: if you divide two polynomials you get a rational fonction and they can be manipulated as objects too:
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.
Example of use:
%1 = 1+1/3*X-1/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:
%2 = X-1/6*X^3+O(X^4)
Linear algebra: Vectors and matrixes are supported. Example:
Enter a 3x3 matrix:
Compute its determinant:
The functions rank, ker, charpoly and eigenvals yield respectively the rank, kernel, characteric polynomial and eigen values of a matrix.
Vectors are also supported:
When dealing with matrix multiplication, they are considered as column vectors, e.g:
[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 component-wise.
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
Mod(a, n) represents the residue of a modulo the
integer n. It supports the usual operators:
Polynomial modulo P: PolyMod works the same way
as Mod but with polynomials:
NumCalc borrows many ideas
It uses the libbf library for
big integer and floating point number operations.