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:
8_ is a variable containing the last result:
Fractions: NumCalc tries to give exact results with fractions:
5/6fractions 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^256yields 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:
0.47619047619047619047619047619047617The 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=113 bits (~34 digits), exponent size=15 bits
\p 192 1/7.0
0.14285714285714285714285714285714285714285714285714285714287Shortcuts 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, ...
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.
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 objects
Complex numbers: use the constant I to enter complex numbers:
(1+2*I)*(2+3*I)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.
X^3+3*X^2+3*X+1You 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:
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+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:
Linear algebra: Vectors and matrixes are supported. Example:
a=[[1,2,3],[2,3,4],[5,6,8]]Compute its determinant:
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:
[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 polynomials.
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:
CreditsNumCalc borrows many ideas from PARI/GP and calc.
DirectivesDirectives change the state of the command line user interface. They are preceeded by the antislash character.
Linear Algebra, Matrixes
Polynomial, Rational functions, Power series