Tusanga calculator
  |  Home  |  Features & Tour  |  Help & Support  |  Sign-up  |  
Menu
Hot Topics
The following is meant as a reference guide for the system. It describes the different expressions, data types and operators that are supported.

Expressions

Basic data types
Basic data types include integers, rational numbers, floats, booleans and textstrings.
Example : 123; 4/6; 14.6; 2e-6; true; "Hello world!"

Numbers are assumed to be decimal when not otherwise indicated. Numbers in other number systems are entered as 0b1101 (binary), 0o700 (octal), 0d100 (decimal), 0x2f (hex) or 0h2f (hex). Yet other systems can be used: xxx|yy, where xxx is a number in the number system with basis yy<=36. Roman numerals er entered as mcmlxxxiv|r.
Example : 123|8; 123.45|12;

Textstrings are bounded by double quotes. A backslash is used to indicate a double quote or a backslash in a textstring.
Example : "The \"best\" task ever"; "This is a single backslash \\ in the middle of a textstring";

Arithmetic operators
+ Addition
- Subtraction
* Multiplication
/ Division
! Faculty function
mod Integer modulo, i.e. the rest
div Integer division, the rest is discarded
^ Power
% Percent


Relations
Relations between two expressions are expressed using the following operators:
< less than
<= less than or equal
> greater than
>= greater than or equal
= = equal
<> not equal

The result of a relation is an boolean expression.

Boolean operators
Boolean operators are:
and (&&) Conjunction
nand Negation of conjunction
or (||) Disjunction
nor Negation of disjunction
xor (^^) Exclusive disjunction
not (~) Negation
-> Conditional / implication
<- Reverse conditional / implication
<-> Biconditional / biimplication

For four of the boolean operators the word form and the symbol are interchangeable. (x and y) is the same as (x && y)
For bitvectors the bv... functions are available. Please see the functions page.

Intervals
Intervals are entered as [x..y], ]x..y], [x..y[ and ]x..y[.
Example : [2..6[

Complex numbers
Complex numbers are constructed using the imaginary unit (i).
Example : 2+3*i

Vectors and matrices
Vectors and matrices are entered using braces {} as delimiters. Use commas to separate elements of a row vector or of a row in a matrix - use semicolons to separate rows in a matrix.
Example : rowvector:= {1,2,3}; columnvector:={4;5;6}; matrix:={1,2;3,4}

Indices to a matrix are surrounded by square bracket []. Indices of first row and column are one - not zero. Indices are integers or integer intervals.
Example : M[2,3]:= 24
Example : M[[1..2],3]:= {24;31}

Operators only working on matrices and vectors include:
.* Matrix multiplication, element by element
./ Matrix division, element by element
.^ Matrix power operator, element by element
` Matrix transposing

Example : a:={1,2;3,4}; a.*a; a./a; a.^a; a`

Sets
Sets are stored and manipulated as vectors.
Example : a:={1,2,3,4}; b:={3,4,5,6}; intersect(a,b)

Choices
Choices are made with the expression if-then-else.
Syntax : if <boolean expression> then <expression> else <expression>
Example : if 3>a then [1..2] else [3..4[

Evaluation
The evaluation of an expression can be delayed using the delay operator (').
Example : 2+'a+3'

When the first character entered is a ', the whole input is assumed to be a comment.
Example : ' This is a comment

The function eval(exp,level) evaluates the expression up to a certain level:
1: Basic rules of arithmetic, e.g. 2 + 3 = 5, are applied. Variables and functions are not evaluated
2: Variable names are substituted with their definition once. Function call parameters are evaluated
3: (Standard) Variables are treated like on level 2, only recursively. Functions are evaluated
4: Expressions are evaluated to floating point values were applicable
Function evalf(exp) is defined as eval(exp,4)

Constants
A number of constants are known to the system:
i, pi, e and inf.

goto top
  |  About  |  Terms of Use  |  Privacy Policy  |  Contact  |  Impressum  |  FAQ  |