Use standard syntax to type an expression.
Press ENTER to execute.
Example:
Use C/C++/Java syntax.
There is no need to declare variables.
Example:
Use a ";
" to enter several expressions in one line.
Example:
You may prefer doing this:
Variables can be redefined to be rational, real, complex, boolean, array, string, or matrix.
The sample session may continue like this:
Variable x was redefined as an array of size 3 (arrays of size 3 are also treated as vectors.)
The ans variable always has the value of the last successful calculation.
Example:
Valid variable names can be formed using letters, numbers, underscores, single quotes and backslashes. However, a variable name must not start with a number. Calcugator is case sensitive.
A Calcugator letter is defined as any unicode character that the java language recognizes as a letter. See examples below
This example uses a Greek letter. Menu option File->Unicode Chooser... lets you enter unicode characters.
See the documentation of function shortcut()
for details on how to enter unicode characters.
The following are predefined constants:
pi = 3.14159
e = 2.71828
i, j = sqrt(-1)
(the imaginary number)These constants can not be redefined.
If an expression involves only integers and/or rational numbers, the program will try to keep the result as an integer or a rational value. Common factors are simplified.
Examples:
The following operators or functions can be used with integers and rational numbers:
x mod y
returns the integer residue of dividing integer x
by integer y
.
int x
returns the integer truncation of the real x
.
factors(x)
returns an array with all factors of integer x
.
primes(n)
returns an array of size n
containing the first n primes except 1.
ceil(x)
returns the smallest integer bigger than the real x
.
floor(x)
returns the biggest integer smaller than the real x
.
lcm(x,y)
returns the least common multiple of integers x
and y
.
gcd(x,y)
returns the greatest common divisor of integers x
and y
.
fix(x)
returns the integer obtained by rounding x
towards zero.
round(x)
returns the integer obtained by rounding x
to the nearest integer.
numerator(x)
returns the numerator of the rational number x
.
denominator(x)
returns the denominator of the rational number x
.
Every number entered with a period or in exponential format is treated as a real number.
Every operation involving at least one real number makes the result real.
Precedence and associativity of arithmetic operators follow strict C/C++/Java conventions.
The following operators and functions are implemented:
+, -, *, /
and unary minus.
x ** y
returns x
to the power y
.
pow(x,y)
returns x
to the power y
.
x^y
also returns x
to the power y
.
sin(x), cos(x), tan(x), asin(x), acos(x)
and atan(x)
.
sinh(x), cosh(x), tanh(x), asinh(x), acosh(x)
and atanh(x)
.
atan2(x,y)
returns the angle whose tangent is y/x
.
log(x), log10(x), exp(x), sqrt(x)
and abs(x)
.
toRad(x), toDeg(x)
are convenience functions to pass from radians to degrees.
sign(x)
returns 1
if x
is positive; it returns -1
otherwise.
Numerical exceptions are never thrown.
You may work with infinite values and NaN (not a number).
Example:
Infinity
and NaN
may be assigned to variables.
Example:
Enter complex numbers using the predefined variables i
or j
.
Example:
NOTE: To enter imaginary parts make sure a number precedes the imaginary constant:
All functions which work for real numbers, also work for complex numbers.
Functions asin(x)
and acos(x)
return NaN
if the argument x
is real and it is outside the interval [-1.,1.]
.
However, if you need a complex result, add a 0j
to the argument to have a complex result.
Example:
The following functions accept complex arguments:
conjugate(x)
returns the conjugate of x
.
Re(x)
returns the real part of x
.
Im(x)
returns the imaginary part of x
.
angle(x)
returns the angle between 0 and 2*pi.
All C/C++/Java boolean operators are supported.
Example:
Create an array as follows:
A quick way to create an array is to create a specific entry:
Arrays can be resized by creating an entry at a new position:
Use the []
operator to dereference any entry of an array inside algebraic expressions.
You may also create arrays using the array
function:
array(n, x1, x2)
or
array(n, x1)
where n
is the size of the array to create. The value for the first entry is x1
, the value for the last entry is x2
and the values of the remaining entries are found by linear interpolation. If x2
is missing, all entries will have the value x1
.
Use arithmetic operators +
and -
provided the arrays are of the same size.
You may multiply and divide arrays times scalar values (rational, real, complex) using the *
and /
operators.
The following functions can be used with array arguments:
transpose(v)
returns a column matrix with the values of v
.
abs(v)
returns the norm of the array v
.
size(v)
returns the size of the array.
logarray(n1, n2)
returns a new array created with entries: 10^n1
, 10^(n1+1)
, 10^(n1+2)
,...10^n2
. Both n1
and n2
must be integers.
subarray(a,n1,n2)
returns the following array: ( a[n1], a[n1+1], a[n1+2],..., a[n2])
. Both n1
and n2
must be integers. If n2
is not specified, the last entry corresponds to the last entry of array a
.
reverse(a)
returns a new array with the entries of a
in reverse order.
apply(a, f)
transforms array a
by applying function f
to each of the entries.
join(a,b)
transforms array a
by adding all entries of array b
.
swap(a,i,j)
swaps entries i
and j
of array a
.
normalize(a)
returns a unit vector in the same direction as that of a
. Array a
must be of size 3.
The following functions are implemented:
max(...)
returns the maximum value of the arguments passed.
min(...)
returns the minimum value of the arguments passed.
show()
displays a list of all user defined variables and functions in the current session.
set(...)
sets a property. See list below.
The properties that may be set and the type of the parameter needed are the following:
"matrixSingularityTolerance"
, a real.
"formatDecimalDigits"
, an integer.
"formatSignificantDigits"
, an integer.
"formatUpperBound"
, a real.
Property formatSignificantDigits refers to the number of significant digits used to print a number in engineering format.
Property formatUpperBound is a positive value; if the absolute value of a number x
is bigger than formatUpperBound, the exponential format is used to print the value of x
; if the absolute value of x
is less than formatUpperBound, then x
is printed using as many decimals as formatDecimalPlaces.
Integers don't follow the rule above, they are printed using the maximum number of digits possible.