## Overview

Use standard syntax to type an expression.
Press ENTER to execute.

Example:

4*7/(3-5/(3-7*3))
504/59

Use C/C++/Java syntax.
There is no need to declare variables.

Example:

x=4
4
5*x/(3+x)
20/7

Use a "`;`" to enter several expressions in one line.

Example:

x=4; 5*x/(3+x)
4
20/7

You may prefer doing this:

5*(x=4)/(3+x)
20/7

Variables can be redefined to be rational, real, complex, boolean, array, string, or matrix.

The sample session may continue like this:

x=(5, 6, 7)
5  6  7
y=(-3, 1, 3)
-3  1  3
z=x cross y
11  36  23

Variable x was redefined as an array of size 3 (arrays of size 3 are also treated as vectors.)

### The ans Variable

The ans variable always has the value of the last successful calculation.

Example:

5*4
20
ans*2
40

### Variable names

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

x=77
77
A=5
5
a'=8
8
x*a'
616
_my_\s = 99.99
99.99

This example uses a Greek letter. Menu option File->Unicode Chooser... lets you enter unicode characters.

α=5
5
α*α
25

See the documentation of function `shortcut()` for details on how to enter unicode characters.

### Constants

The following are predefined constants:

• `pi = 3.14159`
• `e  = 2.71828`
• `i, j  = sqrt(-1)` (the imaginary number)

These constants can not be redefined.

### Rational numbers and integers

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:

A=3*(5, 7/3, 3/2, 1/7)
15  7  9/2  3/7
B=(1, 2, 3 ; 4, 0, 0 ; 0, 1, 2)
1  2  3
4  0  0
0  1  2
inverse(B)
0  1/4  0
2 -1/2 -3
-1  1/4  2

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`.

### Real numbers, Infinity and NaN

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:

• Arithmetic operators `+, -, *, / ` 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`.
• Trigonometric functions `sin(x), cos(x), tan(x), asin(x), acos(x)` and `atan(x)`.
• Hyperbolic functions `sinh(x), cosh(x), tanh(x), asinh(x), acosh(x)` and `atanh(x)`.
• `atan2(x,y)` returns the angle whose tangent is `y/x`.
• Functions `log(x), log10(x), exp(x), sqrt(x)` and `abs(x)`.
• Functions `toRad(x), toDeg(x)` are convenience functions to pass from radians to degrees.
• Function `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:

1/0
Infinity
asin(3)
NaN
atan(-1/0)
-1.5708

`Infinity` and `NaN` may be assigned to variables.

Example:

x = -Infinity
-Infinity
3*x
-Infinity
sin(NaN)
NaN

### Complex numbers

Enter complex numbers using the predefined variables `i` or `j`.

Example:

z = 3 + 3j
3.0000 + 3.000 j
sin(z)
1.4207 - 9.9176 j

NOTE: To enter imaginary parts make sure a number precedes the imaginary constant:

// OK, Re(z)=4 and Im(z)=1
z=4+1j
(4.0 + 1.0 j)
// May generate an error because it is
// interpreted as the sum of variable "j" and 4
z=4+j

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:

asin(1.2)
NaN
asin(1.2+0j)
1.5708 - 0.6224 j

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.

### Boolean expressions

All C/C++/Java boolean operators are supported.

Example:

a = 3<5
true
a && false
false
(2<=5 || 4>-1) && (asin(.707)<pi/2)
true

### Arrays

Create an array as follows:

v=(2,4, 5, 6, -3, 9)
2  4  5  6  -3  9

A quick way to create an array is to create a specific entry:

D = 5
5
D
0  0  0  0  0  0  0  5

Arrays can be resized by creating an entry at a new position:

D=-4
-4
D
0  0  0  0  0  0  0  5  0  0  0  -4

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.

### Miscellaneous functions

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.