Chapter 4. Calculator Modes
Prev |  | Next

# Chapter 4. Calculator Modes

Qalculate! provides flexible parsing, calculation output and result display. There are several ways in which parsing of expression and display of results can be customized. These modes can generally be changed through the mode menu. The state of each mode can be saved under a name in Mode → Meta Modes for quick access. The Preset and Default meta modes are always available and represents the state when Qalculate! is load for the first time and the mode settings automatically loaded at each startup (and by default saved on exit), respectively. Different modes are summarized below.

Number Bases

  Non-decimal bases can be selected for display of numbers in the result. This include regular number bases (binary, octal, hexadecimal, sexagesimal) as well as sexagesimal time format and roman numerals. All number bases between 2 and 36, and base for expression input, can be selected from a dialog window accessed from Mode → Number Base → Other... or Mode → Number Base → Select Result and Expression Base.... Note that duodecimal (base 12) numbers use upside down 2 and 3 (or 'X' and 'E'), instead of 'A' and 'B', for the tenth and eleventh digit. The convert number bases dialog (see the section called “Convert Number Bases Dialog”) is efficient for simple conversion between common bases.

Numerical Display

  These modes mainly control when numbers are displayed exponentially (e.g. “2.62E3” which equals “2620”). In the default normal mode, numbers are displayed in exponential format if the exponent will be greater than the current precision. In scientific mode the lowest exponent is 3. In simple numerical mode the exponential format is never used and it is always used in purely scientific mode. In the engineering mode, the exponent is always a multiple of three. This is naturally equivalently true for numbers less than one and negative exponents. When the scientific modes are selected in the keypad (not from the menubar), negative exponents are automatically activated and sort minus last deactivated, while normal and simple modes do the opposite.

Indicate Repeating Decimals

  If this option is on, Qalculate! will not round infinitely repeating digit sequences, if the digits in the sequence fits the maximum number of decimals. Instead “…” will be displayed after the repeated digits and the result indicated as exact (compare “9/11 ≈ 0,81818182” with “9/11 = 0,81 81…”).

Round Halfway Number To Even

  With this option, halfway numbers will be rounded to even instead of upwards (e.g. 2.65 is then rounded to 2.6 instead of 2.7). Note that this behavior is always applied in the round() function.

Show Ending Zeroes

  if this option is on, approximate numbers in the result will be appended with zeroes, so that the number of digits (after preceding zeroes) will equal the precision.

Negative Exponents

  If negative exponents is activated, division is shown as a negative power (e.g. “x * y^-1” instead of “x / y”).

Sort Minus Last

  This option decides if minus signs should be avoided in the first positions of the result expression.

Complex Number Form

  Complex number can be displayed in rectangular/cartesian (e.g. “5i + 2”), exponential (e.g. “5.39 * e^1.19”) or polar form (e.g. “5.39 * (cos(1.19) + i * sin(1.19))”).

Fractional Display

  This controls if numbers are displayed in fractional or decimal mode. Decimal mode displays numbers as usually expected (“6/4 = 1.5”), combined displays a whole number and a fraction (“6/4 = 1 1/2”) and fractional only displays as fraction (“6/4 = 3/2”).

Unit Display

  The automatic use of prefixes for units in results can be toggled on and off. By default prefixes are only used for a selection of units (mainly standard SI and CGS units), but this can be changed to also include currencies or all other units. By default prefixes representing a power of ten not dividable by three (centi, deci, deca and hekto) are not used and need to be enabled. If denominator prefixes are not explicitly enabled, prefixes will only be set for the numerator in a fractional unit expression (e.g. “1 Mg/m” or “1 kg/mm”), unless there is no unit in the numerator. The place units separately alternative controls the display of unit expressions in result. If it is enabled (default) units will be displayed separate from other parts of the expression at the end (compare “(5x*m)/(y*s)” and “5x/y m/s”).

  Units can be automatically converted to base units or the optimal units in results. Optimal conversion means that the number of units in the result is reduced to as few units as possible. Only SI units are used for conversion. If Convert to Optimal SI unit is activated, non-SI units are converted to SI units, even if equally or less optimal than the original unit(s). In optimal unit mode, currencies are converted to the local currency, unless deactivated in the preferences dialog. Mixed units conversion allows certain units, such as time units and many imperial/U.S. customary units, to be converted to a combination of appropriate units, e.g. “60.2 minutes = 1 hour to 12 seconds”.

Abbreviate Names

  The display of unit, prefix, variable and function names can be controlled by selecting to display abbreviations or full length names (e.g. “5 cm” or “5 centimeters”). Both abbreviations and long names can however always be entered in expressions.

Approximation

  When always exact mode is on, the calculation will not go further than what can be calculated exactly (e.g. “sqrt(2+3) = sqrt(5)”). The default “Try Exact” mode, will calculate the result exact as far as possible and then approximately. Approximate mode will directly calculate a approximate result, thus being a bit faster but giving a less correct approximate indication (“sin(pi/2)” return approximately one instead of exactly one). If the interval arithmetic mode is activated the precision of the final result is guaranteed by calculating an interval for every approximate value (See Chapter 5, Propagation of Uncertainty and Interval Arithmetic).

Assumptions

  This controls the default assumptions for unknown variables without explicitly defined assumptions. See Chapter 6, Variables. The assume denominators non-zero alternative makes it possible to avoid the situation where expressions such as “(x-1)/(x-1)” can not be further simplified because the denominator might be zero (if x equals 1). With this alternative activated the example can be reduced to 1.

Parsing Mode

  These options controls how expressions are interpreted. There are three main modes, which mainly controls if implicit multiplication is handled differently from explicit multiplication and if spaces are taken into account or not. See the section called “Implicit Multiplication and Parsing Modes”. If the read precsion option is activated, decimal numbers are intrepeted as approximate with precision equal to the number of digits (e.g. “1.1 * 3.20 = 1.1±0.05 * 3.20±0.005 ≈ 3.5±0.2”).

Precision

  Precision specifies the default number of significant digits displayed and determines the precision used for approximate calculations. The internal precision is higher than the one specified, but will nevertheless not completely protect against loss of significance/catastrophic cancellation (and you will not be alterted unless interval arithmetic is activated).

Decimals

  In the decimals dialog, the number of decimals displayed can be controlled. This includes minimal (will fill out with zeroes) and maximal number of decimals (will round numbers).

## The RPN Mode

The Reverse Polish Notation mode can be activated from Mode → RPN Mode, Ctrl+R or from the context menu of the expression entry. For details about what Reverse Polish Notation is and how it generally works, see for example the RPN article at Wikipedia.

Central to the RPN mode is the stack, a list of registers/values that is operated on by functions and operators. The stack has a variable number of registers which can hold an unlimited number of values. The stack size is dynamically changed when a new value is added and the first value on the stack is shown in the result display. Mathematical operators such as plus and minus then operates on the first two, last added, values on the stack. The second value is changed with input from the first value. For example, the minus operator subtracts the first value from the second.

For example, 5 ENTER 3 + 2 / adds 5 to the stack, then adds 3 to the stack and moves 5 down a step and adds 3 to 5. The first value, 3, is removed from the stack and the value left is 8. Then 2 is added to the stack and 8 is divided by 2, resulting in 4. This would in a single expression with non-RPN (infix) syntax be entered as “(5+3)/2”.

Functions operate on the top values of the stack. Functions which require multiply arguments, fill the arguments in reversed order from the top (e.g. 5 ENTER 2 ENTER rem equals “rem(5, 2)”). Functions with a vector argument uses all stack regsters (unless the top value is a vector). This is quite useful for statistical functions (e.g. 5 ENTER 2 ENTER 3 ENTER 4 ENTER harmmean calculates the harmonic mean of 5, 2, 3, and 4 and leaves the result, 3.1169, as the only value on the stack).

When the RPN stack is enabled, full expressions can still be entered (you can add e.g. “5x+3+23+sin(2)” directly to the stack). The buttons on the keypad do not insert operators and functions in the expression entry, but instead applies them to the stack. This is also true for the keys on the keyboard, unless deactivated in the preferences (Edit → Preferences). Enter calculates the current expressions and adds it to the stack (calculated mathematical expressions are automatically added to the stack when the RPN stack is enabled). If the expression entry is not empty when applying an operator or function to the stack, the expression is first calculated and added to the stack. All keys on the main part of the keyboard add the corresponding characters in the expression entry, unless the Use only keypad keys for RPN option is deactivated from the preferences dialog. To apply the raise operator '^' to the stack, without clicking the keypad button with the mouse, use the Ctrl+* (keypad) shortcut. If the expression only contains an operator or a single function without arguments, the operator/function is applied to the stack.

Figure 4.1. RPN Mode

The RPN mode adds a third page to the main window, for display and manipulation of the values on the stack. This shows a list of values on the stack, with the last added value on the top. On the right are buttons for manipulation of the stack. The buttons move the selected value up or down, move it to the top, edit it, or removes it, in order. If no stack row is selected, the up and down buttons rotates the stack, the swap button swaps the places of the first and second value and the copy and delete buttons acts on the the top value of the stack. The last button removes all values from the stack. On the left are buttons for applying mathematical operations to the stack. These works the same as buttons on the separate keypad. Changes in the display of results only affects the first value on the stack.

Reverse Polish Notation can also be used directly in expression. This can be activated or deactivated separately from the RPN stack (Mode → Parsing Mode → RPN Syntax). When using RPN syntax, a temporary stack, separate from the previously mentioned stack, is created from the contents of each mathematical expression entered. To calculate “(5+3)/2”, as in the example above, with RPN syntax you should enter the expression “5 3 + 2 /”. Instead of actually pressing enter on the keyboard, each separate value on the stack is separated by a blank space. The RPN syntax only supports functions that require exactly one argument.

Prev |  | Next
Chapter 3. Expressions | Home | Chapter 5. Propagation of Uncertainty and Interval Arithmetic