# The &qalculate_kde; Handbook

## Introduction

Qalculate! is not your regular software replication of the cheapest available calculator. Qalculate! aims to make full use of the superior interface, power and flexibility of modern computers.

The center of attention in Qalculate! is the expression entry, Instead of entering each number in a mathematical expression separately, you can directly write the whole expression and later modify it. Just enter an expression as you would write it on paper, press Enter and voila!

The interpretation of expressions is flexible and fault tolerant, and if you nevertheless do something wrong, Qalculate! will tell you so. Not fully solvable expressions are however not errors. Qalculate! will simplify as far as it can and answer with an expression.

In addition to numbers and arithmetic operators, an expression may contain any combination of variables, units, and functions. These are immediately accessible from the user interface — the menu bar, the managers, the calculator keypad, and automatic completion.

Qalculate! also has some special tools to increase your efficiency, including a number base conversion dialog and a simple plotting interface.

Although use of Qalculate! for simple calculations should be natural and self-explanatory, reading the rest of the manual can help you maximize your productivity and discover some maybe unexpected features. More advanced users should read on and discover a large number of customization options and the ability to create and modify your own variables, functions and units directly from the user interface.

## User Interface

### Main Window

The main window provides a menu bar, the expression entry, the result display and a calculator keypad or history view which can be shown/hidden by clicking on Keypad and History, respectively. There are three buttons to the right of the expression entry and the result display. The upper button performs calculation of the entered expression (same as Enter), the one below saves the current result as a variable (see qalculate-variable-creation), while the last button opens a dialog for conversion of units in the result (see qalculate-unit-conversion). When non-default options for the interpretion of expressions have been selected, the choice will be indicated in a small status area below the expression entry, to the right.

### Expression Entry

The expression entry is the most important part of the Qalculate! user interface. The normal calculation procedure in Qalculate! is to type in a mathematical expression (ex. 5+5) and press Enter (or click Execute). The result (10) is then displayed below the expression entry in the result display.

#### Completion

Qalculate! helps out with the expression by giving a list of possible endings to words representing functions, variables and units. The list will narrow with each letter typed. Select an item in the list and the name will be completed. If a function was selected, parenthesis will be added and the position moved for immediate entry of arguments.

As the expression is typed in, the area directly direclty below the expression entry, to the left, will show useful information. By default the calculator's interpretation of the expression is shown (ex. 5 * meter for 5m). The interpretation will be displayed in red (configurable) if there are errors in the expression or in blue for lesser errors (for example too many arguments in a function). If the last typed in text represents a function, and arguments are about to be entered, the functions name and its arguments will be displayed. The first argument in the information text is highlighted and includes information about its type and restrictions and when an argument has been entered, the next will be highlighted.

After execution of an expression, the whole expression will be marked. This normally means that if something new is entered, the old expression will be overwritten. If, however, an operator (+, −, *, /, ^) is entered first, the old expression will instead be the target of action. The operator will then apply to the whole expression, which is put in parenthesis. This works on all marked ranges, meaning that this way an expression can conveniently be put in parenthesis. Functions set the selection as their first argument.

The Up and Down keys will access previously entered expressions. With focus in the expression entry, Up traverses backwards in the expression history and Down forward.

The font used for the expression entry can be selected in the preferences dialog (Edit Configure Qalculate!).

### Result Display

The result of calculations is displayed in the open area below the expression entry. The font used for the result display can be selected in the preferences dialog (Edit Configure Qalculate!). Use of Unicode signs can be turned off in the same dialog. Otherwise Qalculate! will try to make the result as fancy as possible and print π for pi, √ for sqrt, € for euro, and so on. Information about customization of the mathematical result output is available in qalculate-result.

In front of the result an equals or approximately equals sign is shown. This indicates whether Qalculate! was able to calculate/display the result exact or only approximate, in the current mode.

The result display has a context menu, which pops up when clicking with the right mouse button anywhere in the field. This menu provides a subset of the display alternatives from the mode menu (qalculate-TBL-mode-menu) and some actions from the edit menu (qalculate-TBL-edit-menu). See more info in qalculate-result. Show Parsed Expression shows how the entered expression was interpreted before the calculation leading to the current result.

When you move the mouse over parts of the result, descriptions will pop up for variables, functions and units. This will only work if you have tooltips enabled in KDE. You can also show this information by double clicking or selecting Show Object Info in the context menu. For matrices and vectors, this will open a window with a spreadsheet-like table displaying the contents of the matrix/vector.

To copy the result, either select Edit Copy Result, or mark and copy the text from the result display or history. Note that all results are not displayed in the result display as an expression which can be used directly in the expression entry. This is true for divisions, powers and vectors. For example, when the result "x^5" is marked and copied, the power sign will be lost.

### Keypad

The keypad provides access to a fairly small set of traditional calculator buttons, which work as expected. The top buttons (from left to right) toggles exact calculation, toggles fractional number display, selects display mode and selects number base in result (see qalculate-result).

#### Keypad

### Calculation History

The history view provides access to previous calculation results (50 rows are reloaded on restart). Previous expressions and results, as well as errors and warnings, are displayed in plain text and can be marked and copied (from the right-button context menu or with Ctrl C) to the expression entry or elsewhere.

#### Calculation History

### Menu Bar

The menus in the menu bar provides access to most of the functionality of Qalculate!. Their contents are listed and described below.

### File Menu

Menu Item | Description
New | Submenu for creation of new objects. See qalculate-TBL-new-menu.
Import CSV File... | Opens a dialog for import of a data file as a matrix or vectors.
Export CSV File... | Opens a dialog for export of a matrix or vector to a data file.
Store Result... (Ctrl S) | Stores the current result as a variable. See qalculate-variable-creation.
Save Result Image... | Saves the result display to a PNG image.
Save Definitions | Saves all user definitions (variables, functions and units).
Update Exchange Rates | Downloads current exchange rates from the Internet.
Plot Functions/Data | Opens the plot dialog. See qalculate-plotting.
Convert Number Bases | Opens the number bases converter. See qalculate-convert-number-bases-dialog
Periodic Table | Shows a periodic table, with property values which can be inserted in the expression, in a new window.
Quit (Ctrl Q) | Exits Qalculate!

### New Menu

Menu Item | Description
Variable | Opens the variable edit dialog for creation of a new variable.
Matrix | Opens a dialog for entry of a new matrix variable.
Vector | Opens a dialog for entry of a new vector variable.
Unknown Variable | Opens the variable edit dialog for creation of a new unknown variable.
Function | Opens the function edit dialog for creation of a new function.
Data Set | Opens the data set edit dialog for creation of a new data set.
Unit | Opens the unit edit dialog for creation of a new unit.

### Edit Menu

Menu Item | Description
Manage Variables (F2) | Opens the variable manager. See qalculate-managers.
Manage Functions (F3) | Opens the function manager. See qalculate-managers.
Manage Units (F4) | Opens the unit manager. See qalculate-managers.
Manage Data Sets | Opens the data set manager.
Factorize | Factorizes the current result. For multivariate rational polynomials, only square free factorization is supported.
Simplify | Simplifies the current result. Note that easy simplifications are always automatically performed.
Set Unknowns... | Opens a dialog where the values of unknown variables in the result can be set and the result recalculated.
Convert To Unit | Submenu with units. Select a unit to convert the current result.
Set Prefix | Submenu for choice of unit prefix in current result.
Convert To Unit Expression (Ctrl T) | Opens the convert to unit dialog for conversion of result to custom unit expression. See qalculate-unit-conversion.
Convert To Base Units | Splits up unit(s) in the current result into base units.
Convert To Best Unit | Tries to convert the units in the current result so that as few units as possible is used. Base units are prioritized.
Insert Matrix | Opens a dialog where you can create a matrix in a spreadsheet-like table and insert into the expression entry. If selected expression text is a matrix, then the matrix is edited.
Insert Vector | Opens a dialog where you can create a vector in a spreadsheet-like table and insert into the expression entry. If selected expression text is a vector, then the vector is edited.
Copy Result (F5) | Copies the current result to the clipboard.
Configure Qalculate! | Opens the preferences dialog, which controls settings for visual appearance and start/exit actions.
Configure Shortcuts... | Opens a dialog for configuring keyboard shortcuts.

### Mode Menu

Menu Item | Description
Number Base | Submenu with a list of number bases (binary, octal, decimal, hexadecimal, sexagesimal, time format, and other bases, and roman numerals) to select for result display, and a menu item (Ctrl B) for opening a dialog to switch number bases in expression (input) and result (output).
Numerical Display | Submenu which selects numerical display mode. See qalculate-result.
Fractional Display | Submenu which selects decimal, fractional or combined fractional display. See qalculate-result.
Unit Display | Submenu which controls the display of units and prefixes. See qalculate-result.
Angle Unit | Submenu which sets the default angle unit for trigonometric functions.
Abbreviate Names | Toggles on/off use of abbreviation for unit, prefix, variable and function names in result display.
Enabled Objects | Submenu which enables/disables variables, functions, units and unknowns (will not affect defined unknown variables and quoted unknowns), and calculation of variables (If calculation of variables is not on, all variables will be treated as unknown). Here you can also disable complex and infinite results.
Approximation | Submenu which switches between different approximation modes.
Assumptions | Submenu which changes default assumptions for unknown variables.
Algebraic Mode | Submenu with options to automatically simplify or factorize the final result. Note that even if this is set to none, easy simplifications will be performed. In this menu, the option toggle on/off use of the assumption that unknown denominators not are zero is also found. This 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).
Read Precision | Enables/disables interpretation of input numbers with decimals as approximate with a precision equal to the number of digits (after preceding zeroes).
Limit Implicit Multiplication | Activates/deactivates limits to implicit multiplication when parsing and displaying expressions. For details see qalculate-result
RPN Mode (Ctrl R) | Toggles Reverse Polish Notation mode on/off. For details see qalculate-rpn
RPN Syntax | Toggles use of Reverse Polish Notation syntax in expressions on/off.
Precision | Opens a dialog to change precision in calculations.
Decimals | Opens a dialog to change displayed number of decimals.
Meta Modes | Provides a list of available meta modes for loading and menu items to save and delete modes.
Save Default Mode | Saves the current calculator mode as the startup default.

### Functions Menu

Menu Item | Description
(Recent functions list) | Select a function to open the insert function dialog.
(Function list) | Select a function to open the insert function dialog.

### Variables Menu

Menu Item | Description
(Recent variables list) | Select a variable to insert it into the expression entry.
(Variable list) | Select a variable to insert it into the expression entry.

### Units Menu

Menu Item | Description
(Recent units list) | Select a unit to insert it into the expression entry.
(Unit list) | Select a unit to insert it into the expression entry.

### Help Menu

Menu Item | Description
Qalculate! Handbook(F1) | Invokes the KDE Help system starting at the Qalculate! help pages. (this document).
What's This?(Shift F1) | Changes the mouse cursor to a combination arrow and question mark. Clicking on items within Qalculate! will open a help window (if one exists for the particular item) explaining the item's function.
About Qalculate! | This will display version and author information.
About KDE | This displays the KDE version and other basic information.

### Variable/Function/Unit Managers

The manager windows provide a structural way of working with variables, functions and units (collectively referred to as objects). The managers for the three different objects are essentially similar. They can be opened from the edit menu. F2, F3 and F4 can also be used for variables, functions and units respectively. The function manager can also be opened with the f(x) button in the keypad.

#### Variable Manager

To the left is a category tree and beside that is a list of all objects in the selected category, including all subcategories. Objects without a category are put under Uncategorized. The top category, All, provides a list of all objects, except those that are deactivated and available in the second top-level category — Inactive. The object list does, in addition to descriptive names, for variables have an extra column for values of variables, and units have additional columns for abbreviation/singular/plural and base unit.

The buttons on the right work on the selected object in the list. New opens a dialog for creation of a new object, while Edit opens the same dialog to edit the selected unit. Insert inserts the object into the expression entry in the main window, Delete removes the object and (De)activate toggles recognition in expressions on/off. The unit manager has an additional button for conversion of the current result and the variable manager a button for export to a data file.

#### Function Manager

The function manager has a description box at the bottom, which shows the syntax, description and arguments of the selected function.

#### Unit Manager

The unit manager has an area for quick conversion between units. This converts between the selected unit in the list and the selected unit in the option menu. The menu contains the same units that are available in the list. Units are converted by specification of a quantity, in the entry next to the unit to convert from, followed by Enter.

For more information about variables, functions and units, see qalculate-variables, qalculate-functions and qalculate-units.

### Convert Number Bases Dialog

The number bases dialog, accessible from the File Menu, is an efficient and convenient tool for conversion between binary, octal, decimal and hexadecimal numbers. This dialog contains entries for each number base. When a number is typed in any of the entries, the others are automatically updated to display the current number in their format. Numbers, or expressions, entered follow the same rules as expressions in the main expression entry.

#### Convert Number Bases Dialog

## Expressions

Expressions are mathematical statements. Mathematical questions are asked through expressions, which contains objects tied together with operators. The result of an expression may also be an expression, if the result is not a single object. Apples and oranges can be mixed, but the result will hold them apart. Qalculate! knows algebra.

### Objects

In Qalculate! mathematical entities, such as numbers and variables, are referred to as objects. The recognized object types are listed below.

Numbers

- These are the regular numbers composed by digits 0-9 and a decimal sign — a dot, or a comma if it is the default decimal point in the locale/language used. If comma is used as decimal sign, the dot is still kept as an alternative decimal sign, if not explicitely turned off in the preferences dialog with Ignore dots in number (to allow it to be used as thousand separator instead). Numbers include integers, real numbers, and complex numbers. The imaginary part of complex numbers are written with as regular number followed by the special variable i, which represents the square root of -1 (ex. 2 + 3i). Spaces between digits are ignored (5 5 = 55). E (or e) can be considered as a shortcut for writing many zeroes and is equivalent to multiplication by 10 raised to the power of the right-hand value (ex. 5E3 = 5000).

  Sexagesimal numbers (and time) can be entered directly using colons (ex. 5:30 = 5.5). A number immediately preceeded 0b, 0o or 0x are interpreted as a number with base 2, 8 or 16, respectively (if the default base is 10, ex. 0x3f = 63). The number base in can also be selected, either by using the `base()`, `bin()`, `oct()`, `hex()` and `roman()` functions, or by setting the base used for all numbers in the whole expression from Mode Number Base Select Result and Expression Base....

Vectors and Matrices

- A matrix is a two-dimensional rectangular array of mathematical objects. Vectors are matrices with only one row or column, thus one-dimensional sequences of objects, Vectors and matrices are generated by `vector()`, `matrix()` and similar functions, or stored in a variable. Syntax in the form of [1, 2, 3, 4] and [[1, 2], [3, 4]] can also be used.

Variables/Constants

- See qalculate-variables.

Functions

- See qalculate-functions.

Units and Prefixes

- Qalculate! understands abbreviated, plural and singular forms of unit names and prefixes. Prefixes must be put immediately before the unit to be interpreted as prefixes — 5 mm = 0.005 m, but 5 m m = 5 m^2. Also, for convenience units allow the power operator to be left out. A number following immediately after a unit is interpreted as an exponent (ex. 5 m2 = 5 m^2). This does not apply to currencies, as they might be put in front of the quantity. More information in qalculate-units.

Unknowns

- Unknowns are text strings without any associated value. If Qalculate! finds a character that are not associated with any variable, function or unit in an expression, then it will be regarded as an unknown variable. These are temporary unknown variables with default assumptions. Unknowns can also be explicitly entered by putting a text string in quotes. This is also necessary for undefined unknown variables with more than one character (ex.xy is just one object, while xy means x * y). See qalculate-variables.

Text

- This category represent a number of different function argument types, such as regular text, dates and file names. They can, but do not need to be put in quotes except when containing the argument separator (, or ;).

To avoid confusion, functions, units, variables and unknown variables can independently be disabled.

Variables, functions and units are all accessible in the menus and in the variable, function and unit managers, If their names are not remembered. Functions accessed this way has some extra conveniences. If the function has at least one argument, a dialog will pop up where arguments can be entered and a description of the function and its arguments is available.

Qalculate! can handle most commonly used symbols for certain variables, functions and units, even though most are difficult to find on a keyboard. These include π for pi, √ for sqrt, € for euro, and so on. Most importantly it is possible to copy these symbols when used in the result.

For more information about variables, functions and units, see qalculate-variables, qalculate-functions and qalculate-units.

### Operators

The following operators are defined in Qalculate! and may be used in expressions.

### Operators

Operation | Symbol | Description | Example | Result
Addition | + | Adds the right value to the left value. | 1 + 1 | 2
Subtraction | − | Subtracts the right value from the left value. | 1 − 1 | 0
Multiplication | ⋅ or * | Multiplies the left value by the right value. | 2 * 2 | 4
Division | / | Divides the left value by the right value. | 2 / 2 | 1
Exponent | ^ | Raises the left value by the right value. Can also be typed as **. Note that x^y^z equals x^(y^z), and not (x^y)^z. | 2^3 | 8
10^x | E | Multiplies the left value with 10 raised to the power of the right value. Equivalent to the exponential number format in result display. E is as much an operator as part of numbers. | 1E3 | 1000
Parenthesis | ( and ) | Evaluates the expression in parenthesis first. | 5 * (1 + 1) | 10
Less than | < | Returns 1 for true, if the left value is is less than the right, and 0 for false. | 1 < 2 | 1
Greater than | > | Returns 1 for true, if the left value is greater than the right, and 0 for false. | 1 >2 | 0
Less than or equal | ≤ or <= | Returns 1 for true, if the left value is less than or equal the right, and 0 for false. | 1 <= 2 | 1
Greater than or equal | ≥ or >= | Returns 1 for true, if the left value is greater than or equal the right, and 0 for false. | 1 >= 2 | 0
Equals | = | Returns 1 for true, if the left value equals the right, and 0 for false. | 1 = 2 | 0
Not equals | ≠ or != | Returns 1 for true, if the left value not equals the right, and 0 for false. | 1 != 2 | 1
Logical NOT | ! | Returns 1 for true, if the value to the right is false, and 0 for false. | !(1>2) | 1
Logical OR | || or OR | Returns 1 for true, if the right or left value is true, and 0 for false. | 1>2 || 2>1 | 1
Logical AND | && or AND | Returns 1 for true, if the right and left value is true, and 0 for false. | 1>2 && 2>1 | 0
Bitwise NOT | ~ | Equivalent to -1-x. | ~(0010 | 1100) | -1111
Bitwise Shift Left | << | Shifts the bits of the left value x steps to the left, where x is the value on the right. Implemented as a shortcut for `shift()` | 0011 << 1 | 0110
Bitwise Shift Right | >> | Shifts the bits of the left value x steps to the right, where x is the value on the right. Implemented as a shortcut for `shift()` | 0011 << 1 | 0001
Bitwise OR | | | If a bit is 1 in one of the numbers set it to 1, otherwise 0. Also functions as elementwise logical operator on vectors. | 0010 | 1100 | 1110
Bitwise AND | & | If a bit is 1 in both numbers set it to 1, otherwise 0. Also functions as elementwise logical operator on vectors. | 1010 & 0011 | 0010

The operator names plus, minus, times, per, AND and OR may also be used, surrounded by space, for the corresponding operation (ex. 5 plus 2, but not 5plus2, equals 5 + 2). These operator names are localized, but AND and OR are always available. In addition to these operators there are a couple of shortcuts for certain functions, such as 5! which equals factorial(5).

The multiplication sign can generally be left out. This is not true for numbers (5(5) = 25 but 5 5 = 55). Expressions can also generally be written with or without spaces with the same result (2xsin(2) equals 2 x sin(2) which equals 2*x*sin(2)), but be careful. The vast number of functions and units means that without separating spaces, the result might not be obvious. To avoid confusion Qalculate! can limit the use of implicit multiplication (Mode Limit Implicit Multiplication), so that space, operator or parenthesis must be put between functions, units and variables (in this mode esqrt(5) does not equal e * sqrt(5)). Also note that unit prefixes must be put immediately before the unit, to be interpreted as prefixes (5 mm = 0.005 m, but 5 m m = 5m^2). You can see how to expression was interpreted in the history window.

Usually, mathematical expressions are written as normally expected. Standard operator precedence apply. Expressions are evaluated according to the following priorities:

1. Parenthesis

2. E (10^x)

3. Short multiplication in front of variables, units, functions, parenthesis etc. (ex. 5(2+3)). Note that this implies that 2/5 cm equals 2/(5 cm) and not (2/5) cm

4. Functions (ex. sqrt(2))

5. Exponents (x^y)

6. Multiplication and division (*, /)

7. Addition and subtraction (+, −)

8. Bitwise NOT (~)

9. << and >>

10. Bitwise AND (&)

11. Bitwise OR (|)

12. Comparison (>, <, =, >=, <=)

13. Logical NOT (!)

14. Logical AND (&&)

15. Logical OR (||)

## 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.... The convert number bases dialog (see qalculate-convert-number-bases-dialog) is efficient for simple conversion between common bases.

Numerical Display

- These modes mainly control when numbers are displayed exponentially (ex. 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 Infinite Series

- If this option is on, Qalculate! will not round infinitely repeating digit sequences if discovered. Instead ... will be displayed after the maximal number of decimals and the result indicated as exact (compare 2/3 = 0.666667 with 2/3 = 0.666666...).

Round Halfway Number To Even

- With this option, halfway numbers will be rounded to even instead of upwards (ex. 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 (ex. 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.

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 use of prefixes for units can be toggled on and off. 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 (ex. 1 Mg/m or 1 kg/mm). 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).

Abbreviate Names

- The display of unit, prefix, variable and function names can be controlled by selecting to display abbreviations or full length names (ex. 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 (ex. 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).

Assumptions

- This controls the default assumptions for unknown variables without explicitly defined assumptions. See qalculate-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.

Precision

- Precision controls the precision in approximate numbers and the number of significant digits. If the read precision option is turned on, input numbers with decimals will be interpreted as approximate with a precision equal to the number of digits (ex. 2.50 + 3.4567 = 5.96).

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

Limit Implicit Multiplication

- If the limit implicit multiplication mode is activated, the use of implicite multiplication when parsing expressions and displaying results will be limited to avoid confusion. For example, if this mode is not activated and integrte(5x) is accidently typed instead of integrate(5x), the expression is interpreted as int(e * e * (5 * x) * gr * t) (displayed in history window). The result will then without any error be int(2.3940139x * km^2) instead of 2.5x^2. If limit implicit multiplication is turned on to mistyped expression would instead show an error telling that integrte is not a valid variable, function or unit (unless unknowns is not enabled in which case the result will be 5 "integrate" * x). When implicit multiplication is limited variables, functions and units must be separated by a space, opertor or parenthesis (xy does not equal x * y).

### The RPN Mode

The Reverse Polish Notation mode can be activated with 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. Functions which require exactly one argument operates on the first value on the stack. Other functions, which require multiple arguments, must be entered in normal expression based way.

The RPN mode still allows full expression to be entered (you can add 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 keypad keys on the keyboard. Enter calculates the current expressions and adds it to the stack. 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 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 function, which requires exactly one argument, the operator/function is applied to the stack.

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 be entered as (5+3)/2.

#### 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 moving the selected value up or down, editing or removing the selected value, or remove all values from the stack. The equals buttons do in RPN mode in addition to calculating the expression, add it to the stack.

Changes in the display of result only affects the first value on the stack.

Note that Qalculate! in addition to the RPN mode, has a RPN syntax. The RPN syntax controls how expressions is interpreted. This means that instead of as with a traditional RPN calculator, where each value and operator is put on the stack separately, all values and operators are entered directly in an expression, with ENTER replaced by space (ex. 5 2 + which corresponds to `5 ENTER 2 ENTER +`, and equals 5 + 2 in regular notation).

## Variables

Variables are used to conveniently store a fixed value/result under a name. Variables can store everything that a result may contain, including numbers, units, variables, unsolved expressions and functions etc.

There two different kinds of variables known and unknown. Known variables represents a fixed value, usually a number, while unknown variables represents a range or type of values (ex. a non-negative integer).

Some common constants that can only be approximately represented by a real number, such as pi and e, are special known variables. They are not fixed but are recalculated each time precision changes, thereby not compromising the arbitrary precision of Qalculate!.

The ans variable, which always contains the last calculated result, is another special and useful variable.

The unknown variables x, y and z are predefined. They cannot be deleted, but changed. By default they use the default assumptions.

For a complete list of available variables see qalculate-definitions-variables or the variable manager.

### Variable creation/editing

#### Store Result

The easiest way to create a known variable is to store the current result. This can be done by clicking the STO button or selecting File Store Result.... Type a name for the variable in the dialog that pops up and optionally enter a category and descriptive name to keep variables well organized.

Known variables can also be created from scratch by selecting File New Variable or by clicking New in the variable manager. The value can then be filled in, in the text field below the name, and specified as exact or approximate.

#### New Variable

The dialog for creation of unknown variables are accessed by selecting File New Unknown Variable. Instead of a value, an assumed type and sign can then be entered.

Edit a variable by clicking Edit in the variable manager.

Variables stored in the Temporary category will not be saved after the program exit.

### Vectors and Matrices

Vectors and matrices are most effectively used stored in a variable. Qalculate! provides separate tools for these variables. They use a different dialog, where each element can be edited separately as in a spreadsheet. As with other variables, click Edit in the variable manager to edit a matrix/vector variable, but to create a new, select File New Matrix or File New Vector.

#### Matrix/Vector Edit Dialog

In this dialog, name, category and descriptive name are typed in as usual, but instead of a single value entry, the matrix/vector edit dialog has a table of entries. Select number of rows and columns above. In a vector this only determines how many value entries that are shown in the table and empty entries will be ignored. For matrices, each entry in the table is an element in the matrix. It is possible to switch between matrix and vector in the dialog (the menu item selected only determines the initial mode).

Matrices and vectors can also be loaded from data files. These files most be plain text files with values organized in separated rows and columns. Select File Import CSV File... and a dialog window pops up. First select the file to import and then specify whether if it shall be imported as a matrix or vectors. A name, descriptive name and category can optionally be typed in. If the name field is empty, the file name will be used instead. After that, the row in the file where the data starts should be specified. as well as whether this first row contains column headings. Finally the delimiter, used to separate columns in the file, must be selected. Click OK and variables will be generated from the file. If vectors are to be generated and the file contains more than one column, the name will be used as a subcategory and each variable will add the column heading (or Column 1, Column 2, ...) to the name and the descriptive name.

#### Import CSV Dialog

The `load()` function can be used to access a CSV file directly in an expression. The reversed action is also available with `export()`, or the dialog accessed with File Export CSV File... or from the variable manager.

## Functions

Functions are essentially mathematical formulas. They are used to store expressions with variable values, arguments. To execute a function, the values for a number of arguments need to specified. These arguments are then inserted into the expression, making it possible to calculate.

Functions is normally entered in an expression by writing the name followed by arguments, separated by commas (or semicolons in languages with comma as decimal point), in parenthesis, thus following the syntax `name(arg1, arg2, ...)`. Qalculate! will give a helpful error message if the arguments are not correct.

### Insert function dialog

The insert function dialog presents an easy way to insert a function and its arguments.

Although it can lower the readability of an expression, it is perfectly legal to skip the parenthesis and put the arguments after a space, and end with a space or operator. This is most useful in short expressions with single argument functions (ex. sqrt 5).

Argument types include:

- Free — anything

- Number — a numeric value

- Integer — a whole number

- Symbol — a defined or undefined unknown variable

- Text — a free text string

- Date — a date in local or standard format (Year-Month-Day, recommended)

- Vector

- Matrix

- Boolean — 0 for false, 1 for true

- Object — the name of a variable, function or unit

- Variable — the name of a variable

- Function — the name of a function

- Unit — the name of a unit

- File — the path to a file

- Angle — an angle used in trigonometric functions, meaning a number and an angle unit. If no angle unit is included the default is used.

The argument can be restricted by further conditions. For example that a number must be positive.

### Available Functions

Here the main function categories and some of their members are described, to give an overview of available functions. For information about separate functions and a complete list of all available functions see qalculate-definitions-functions or the function manager.

Algebra

- Contains `sum()` and `product()`, which corresponds to the sum and product signs. `solve()` solves equations (ex. solve(x * 2 = 8) returns 4 meaning that x equals 4). Use `solve2()` and `multisolve()` to solve multiple equations with multiple variables.

Calculus

- Includes `diff()`, which calculates the derivative of an expression with optional arguments with respect to (default x) and order (default 1), and a limited integration function.

Combinatorics

- Contains functions such as `perm()` for permutations, `comb()` for combinations, and `factorial()`.

Data Sets

- A data set consists of a set of properties and objects, which can be accessed by a function which takes two arguments — object and property. The function returns the object's value for the selected property. For example, the data in the Elements data set is accessed with the `atom()` function, with the element (referenced using atomic symbol, number or name) and property (ex. weight) as arguments. The special property info displays all properties of the object in a dialog window.

Date & Time

- Includes `days()` and `yearfrac()` which returns the number of days and fractional years, respectively, between two dates.

Exponents & Logarithms

- Standard logarithmic and exponential functions. `ln()` calculates the natural logarithm of a number, while `log()` allows a choice of base as the second argument. The exponential functions does not really add anything beyond the capabilities of the exponential operator, ^.

Economics

- This essentially includes most of the financial functions that are usually found in spreadsheet applications.

Elements

- This category includes functions to retrieve data such as atomic weight. The `atom()` function opens a window with available data of an element. These functions accept the number, symbol or name of the element as argument. The data are loaded on demand.

Geometry

- Category with formulas mostly for calculation of circumference, area and volume of geometric shapes.

Logical

- Some procedural functions mainly for use in other functions. These include `if()`, which tests a conditional expression and returns a value depending on if the expression evaluates true or false, and `for()`, which processes a value while a condition is true.

Matrices & Vectors

- These are functions that generate, access and process matrices and vectors. The `vector()` function generates a vector from a variable number of arguments for elements, while `matrix()` first needs the number of rows and columns and then the elements from left to right. Matrices can also be imported directly from a CSV file with `load()`.

  Separate elements at a specified row and column are accessed with `element()`. Other functions include `det()` for calculation of the determinant of a matrix and `inverse()` which returns the inverse of the given matrix, as well as functions such as `sort()` and `rank()`.

Miscellaneous

- A category for functions that do not fit elsewhere.

Number Theory

- Contains subcategories arithmetics, number bases, and rounding, in addition to functions such as `abs()`, which returns the absolute value of a number, and `gcd()`, the greatest common divisor. `round()` is the standard rounding function (note that halfway numbers are rounded to even). The functions for number bases translates a text string, representing an expression (bases that use letters does not allow variables, functions and units) with numbers in a different base, to a decimal number. Includes `bin()` for binary numbers, `hex()` for hexadecimal numbers, `oct()` for octal numbers and `base()` for numbers in a base between 2 and 36 specified in the second argument.

Statistics

- Contains a lot of functions for descriptive statistics and some statistical tests. Data sets are stored as vectors. Generally, functions with a vector/data set as last argument can take elements/samples as a variable number of arguments directly instead of in a vector (ex. mean(1, 2, 3) equals mean(vector(1, 2, 3))). Also contains the `rand()` function, which returns a pseudo random number between 0 and 1, and does not take any arguments.

Trigonometry

- Trigonometric functions, including `sin()`, `cos()`, `tan()`, `sec()`, `csc()`, `cot()`, and hyperbolic and inverse versions of those. These functions take as argument an angle. If the default angle unit (Mode Angle Unit) is set to none, the argument must have an angle unit appended (degrees, radians or gradians), otherwise the default unit will be appended automatically (and removed from result of inverse functions).

Utilities

- Various utility functions. Most are only useful in definition of other functions. The `save()` function can however be a quick way of storing a value in a variable, and `csum()` can be a powerful tool for data processing. This category also contains some functions, such as `char()` and `ascii()`, that might be useful for programmers. , `replace()` provides an easy way of replacing unknown variables by known expressions in a value (ex. replace(5x^2+x, x, 3) equals 5*3^2+3).

### Function creation/editing

Functions are a bit more complex than variables, but can nevertheless be relatively easily created. File New Function or click New in the function manager and the function edit dialog pops up. This dialog consists of two tabs/pages; the first with general descriptive information and the last for the function definition. First enter a name, used to reference the function in an expression. If an expression is entered a bit further down, then the function will already be fully working. A bit more does however need to be said about the function expression.

The expression of a function is basically a normal expression with placeholders for arguments. These placeholders consists of a backslash and a letter — x, y, z for the 1st, 2nd and 3rd arguments and a to u for argument 4 to 24. They are replaced by entered arguments when a function is calculated. The placeholders naturally also decide the number of arguments that a function requires. For example the function for triangle area (base * height / 2) has the name triangle and the expression (\x*\y)/2, which gives that triangle(2, 3) equals (2*3) / 2 and returns 3 as result. An argument can be used more than one time and all arguments must not necessarily be in order in the expression.

#### Function Edit Dialog

Additionally, optional arguments can be put in the expression with upper-case (X, Y, Z, ...) instead of lower-case letters (x, y, z, ...). The default value can be put in brackets after the letter (ex. \X{2}). The default value may be omitted and is then zero. All additional arguments after an optional argument must also be optional.

A condition that must be true (>0) for the function to be calculated, can optionally be entered in the text field below the expression. This follows the same conventions as function expressions. For example if the second argument must be higher than the first, \y > \x may be entered as condition.

Further, name, type and condition for each argument can be specified.

To keep functions well organized, supply a category, descriptive name and description. A function can also hidden from menus with the corresponding check box, which can be useful for sub functions.

Global, system-wide functions can not actually be changed by the user, but if one of these functions is edited, they are deactivated and seemingly replaced by a new function. This way global functions can be deleted by deactivation. Some functions are however hard-coded and cannot be changed by the user.

## Units

Units give numbers meaning in the real world. They specify what is measured by the numbers and the scale used. Qalculate! fully incorporates units in calculations and includes all standard SI units as well as many non-standard local units. For a complete list of available units see qalculate-definitions-units or the unit manager.

### Currency

Among units, Qalculate! has support for currencies with up-to-date exchange rates. Currencies are normally referenced with the standard three letter code due to name clashes, but a number of currency unit can also be accessed through their regular name and symbol. U.S. dollars can, for example, be referenced both as USD and dollar/dollars, or with the $ symbol.

Current exchange rates are automatically fetched from the European Central Bank on the Internet, the first time Qalculate! is started. By default the exchange rates will thereafter have to be updated manually from File Update Exchange Rates, unless automatic updates are enabled in the preferences dialog.

### Conversion

Expressions can be converted to a specific unit directly in the expression entry with the to operator, which converts the left-hand expression to a specified unit (ex. 5 feet + 2 inches to cm converts the result of 5 feet + 2 inches to centimeters and displays it). Unit expressions may only contain units, prefixes, exponents, multiplication and division. Other elements are ignored.

The unit conversion dialog, accessible from the Convert button, Edit Convert To Unit Expression... or Ctrl T, can also be used. Enter a unit in the dialog that pops up, click Apply or OK and the displayed result is then converted. In this dialog, you can also select a unit from a list accessed by clicking Selector >>. When a unit is selected from the list the expression is updated and Apply automatically pressed.

#### Unit Conversion Dialog

The final way to convert to another unit is to use the predefined units in the Edit Convert To Unit menu or press Convert Result in the unit manager. Edit Set Prefix can be used to select a prefix.

It is also possible to let Qalculate! automagically convert the result to appropriate units with Edit Convert To Best Unit or Edit Convert To Base Units. If instead the corresponding choice is selected from Mode Unit Display, each result will automatically be converted until the choice is deactivated (Mode Unit Display No Automatic Conversion).

### Unit creation/editing

There are three different unit classes in Qalculate! — base, alias and composite units. Base units are units defined as basis for other units. Meters and seconds are typical base units. Alias units is defined in relation to another unit. For example, hour is defined as an alias unit that equals 60 minutes which in turn is defined in relation to seconds. Finally, composite units are defined by a unit expression with multiple units. Composite units often have an alias unit associated with them, as they do not have a reference name on their own. For example, a joule is defined as an alias defined in relation to a composite unit defined as Newton * meter.

Select File New Unit, or click New in the unit manager, and the unit edit dialog pops up.

#### Unit Edit Dialog

First the unit class needs to be selected. Depending on the unit class, different elements in the dialog will be enabled. For all units, category and descriptive name can be specified to keep them well organized. A unit can also be hidden from unit menus with the corresponding check box, which can be useful for some composite units.

Base and alias units normally have three different name forms defined for use in expressions — abbreviation (ex. m), singular (meter) and plural (meters). Composite units only have an internal name, used to reference the unit in definitions of other units.

For base units, the name is all that is needed. For alias units, on the other hand, a base unit, exponent and relation are necessary. For more complex relations an inverse relation can also be specified for conversion back from the base unit. The base unit must not necessarily be of the base unit class and it is recommended that an alias unit is defined in relation to the closest unit (ex. 1ft = 3 hands, 1 hand = 4 in, and 1 in = 0.0254 m). The relation is usually just a number that tells how large quantity of the base unit is needed to get the alias unit (alias unit = base unit * relation). More complex units can specify the relation as a full-blown expression where \x is replaced by the quantity of the base unit and \y is the exponent. For example, Degrees Celsius has the relation \x + 273.15 and the inverse relation \x − 273.15 to the base unit Kelvin. For simple relations, the reversion is automatic and ought not be defined separately. The check box below relation in the dialog specifies if the relation is exact or approximate. The exponent defines the exponential relation to the base unit, so that the alias unit equals the base unit raised to the exponent. For simple unit relations this gives: alias unit = relation * base unit^exponent.

Composite units need a unit expression with multiple units as base, in the base unit field. These expressions may only contain units, prefixes, exponents, multiplication and division (ex. km/h).

## Plotting

Plotting in Qalculate! is done through an external program, Gnuplot. Thus Gnuplot (>= v. 3.7) need to be installed on the computer for plotting to work.

To plot functions or data sets, select File Plot Functions/Data, which brings up the plot dialog. The plot dialog consists of three tabs/pages — the first for the data, the second for the function range and sampling rate, and the last for control of function sampling and appearance.

### Plot Data

Plot functions are normal expressions that represents f(x) in y=f(x) (ex. sin(x)). The x can be specified as a different unknown variable (x, y, z) or a quoted text string (actually any mathematical expression which will then be matched in the plot expression and replaced by the values on the x axis) in the variable entry below the function/data list.

To plot a data set, enter an expression that results in a matrix or vector. Select Vector/Matrix below and vectors will appear as one series and matrices will appear with each column or row (if selected) as a series, If the paired matrix option instead is selected, the first column/row of the matrix will constitute the y-values and the second the x-values.

Type in an expression, press Enter and a new window will open with the plot. The title of the series, the diagram style and smoothing of the line can also be set. The series modified must be selected in the list and to apply changes click Apply. More series that will appear in the same plot window can be added. If the scale of the y values differ, series can be put on a secondary y-axis.

Even though Qalculate! does all the calculations before handing over the data to Gnuplot, the resulting data must only consist of pure numbers, as Gnuplot knows nothing about the functions, variables, units, etc. of Qalculate!.

For functions, the function range — min and max x value, and the number of values or the size of the step between each y value calculated — can be specified in the function range page.

### Plot Settings

A title can be set to appear at the top of the plot, as well as labels for the x and y axis. The appearance can also be controlled by selecting or disabling legend placement, displaying/hiding the grid and borders on the top and the right side of the diagram and choosing color or monochrome graphics. The x and y scales can be made logarithmic by clicking the box on the right and filling in a desired logarithmic base.

To update the plot window, click Apply at the bottom of the dialog.

### Gnuplot

The plot can be saved as an image file. Click Save and select a file name and folder. The extension of the file name will decide the file type (.png for PNG image, .svg for SVG, .ps for postscript, .eps for encapsulated postscript, .tex for LaTeX, and .fig for XFig). Default is to save as a PNG image.

## Credits and License

&qalculate_kde;

Program copyright 2005 Niklas Knutsson nq@altern.org

Documentation copyright 2005 Niklas Knutsson nq@altern.org

&underFDL; &underGPL;
&functionlist; &variablelist; &unitlist; &documentation.index;