First, we will learn how to print a variable which keeps a number. In our example, the variable “x” is assigned to 1000
Click [Output] to see what you are just printed on the screen. Numbers are entered in the usual computer format: with optional decimal point and decimal exponent following the letter e (or E). The numbers 5364 and should be entered like
The basic arithmetic operations are marked with the usual symbols (+ - * / ) . Exponention is performed with the accent character (^). Multiplication and division precede addition and subtraction; any order of evaluation can be forced by parenthesis.
The relational operators
|<=||less than or equal|
|>=||greater than or equal|
Note that ”=” is used in an assignment statement while ”==” is used in a relation. Relations may be connected or quantified by the logical operators
When applied to scalars, a relation is actually the scalar 1 or 0 depending on whether the relation is true or false.
Logical true is the number 1, false is 0.
Also, eps is defined:
Most of the time these will be stored as floating point data (double, IEEE standard 754). They are rounded to 5 significant digits for display, but for calculations the full precision of this format is always preserved (15-16 decimal digits). By switching the format (format long) all significant places are displayed.
As an extension it offers the command format Base Number, which is used to display numbers in a system with arbitrary Base with any Number of significant digits. To display numbers with digits in the binary system we type:
Using format short returns the display mode to default (short decimal). It should be emphasized, that none of the format commands influences the internal representation and accuracy of floating point numbers.
Numbers, which are entered without decimal point and exponent, and which are larger than are stored as exact rational data type. These numbers are internally represented as quotient of two variable length integers (java data type BigInteger), which allows you to perform calculations without any rounding errors. In the first case of the following example a floating point number is generated, in the second case an exact rational:
Each floating point number Z can be converted to an exact number using the command rat(Z). The conversion is accomplished by continued fraction expansion with an accuracy determined by the variable ratepsilon (default: ).
The rat() function is a part of symbolic calculation; in such cases we will need to specify “syms”. You can comment it out, but the code should contain the keyword to let the engine know that we are interested in symbolic evaluation.
Operations between exact and floating point numbers always lead to the promotion of floating point numbers. Calculations can be performed without rounding errors by rationalizing just the first number.
Conversely, the command float(Z) converts numbers into floating point format. Both commands also work for composite data types, like polynomials and matrices, whose coefficients are transformed in one step. Irrational function values of exact numbers and constants like pi remain non-evaluated until the float-command is issued.
You can also use comments in the output:
Imaginary numbers are marked with an immediately following i or j. This will work even if the predefined variables i and j have been overwritten.