DocsMOSAICPages & data

Calculator

5 min read

On this page

The calculator is a canvas item with three modes: Basic (a keypad and a history), Scientific (trigonometry, logarithms, powers, factorials and a memory) and Graph (curves y = f(x) with pan, zoom and a trace cursor). Every mode understands the whole formula language, so you can type round(10/3, 2) or dateAdd(today(), 7, "days") as well as press keys.

Adding a calculator

On a board: dock More > Calculator, or right-click the board > Add > Calculator. The calculator is live from 50 % zoom on (when it is big enough on screen); further out it is drawn as a preview. Click it once to select the item, then click again to use it; drag it by its title strip. Its title shows the mode ("Calculator - Scientific").

Every mode adapts to the size of the item: the keys and their fonts scale with the space (every key row always stays visible), the display shrinks first when room is short (a smaller expression line, then no copy button), the history hides when the calculator is short, and in Graph mode the plot keeps its minimum height while the function list scrolls. A calculator never gets smaller than its mode really needs: about 210 x 205 board units in Basic, 288 x 233 in Scientific and 230 x 196 in Graph (plus the title strip). Switching to a bigger mode grows the item when needed.

Modes

A scientific calculator with its history next to a graph calculator plotting two functions
A scientific calculator with its history next to a graph calculator plotting two functions

The segmented control at the top switches between Basic, Scientific and Graph. The inspector's Calculator section has the same Mode switch and the Angles unit. The mode is saved with the board, and every switch is an undo step.

Basic

Under the mode switch: the history, the expression line with a live preview of the result, the copy button and the keypad.

RowKeys
1C (clear, Esc), (, ), backspace (Backspace), divide
27, 8, 9, multiply, square root
34, 5, 6, subtract, ^ (power)
41, 2, 3, add, % (percent: 50% = 0.5; between two numbers, the remainder: 7 % 2 = 1)
5change sign, 0, ., = (calculate, Enter), ans (the previous result)
  • Enter or = calculates and adds expression = result to the history. Typing works too: digits, operators, brackets and function names go into the expression line, = calculates.
  • After a result, a digit starts a new expression and an operator continues from the result (= 12, then * 2).
  • Click a line of the history to use its expression again. The copy button copies the result.
  • The history keeps the last 50 lines and is saved with the board.

Scientific

The same expression line and history, with an eight-column keypad:

RowScientific keysBasic keys
1MC, MR, M+, M-C, (, ), backspace
2sin, cos, tan, pi7, 8, 9, divide
3asin, acos, atan, e4, 5, 6, multiply
4ln, log (base 10), x squared, x^y1, 2, 3, subtract
5square root, cube root, n!, abschange sign, 0, ., add
6mod, 1/x, 10^x, e^xans, %, = (two keys wide)
  • Function keys (sin, ln, square root, n!...) insert the function with an open bracket, for example sin(. Pressed right after a result, they apply to the result: = 115, then sin gives sin(115).
  • 1/x turns the whole expression into 1/(expression).
  • x squared adds ^2; x^y and ^ insert the power operator; mod inserts the remainder operator.
  • DEG / RAD (the chip next to the expression line, or Angles in the inspector) chooses the angle unit of sin, cos, tan and their inverses: in DEG, sin(30) = 0.5 and atan(1) = 45; in RAD, sin(pi/6) = 0.5. Degrees are the default. The unit is saved with the board.
  • Memory: M+ adds the current result (or the value of the expression) to the memory, M- subtracts it, MR inserts the memory value, MC clears it. An M mark shows while the memory holds a value (its tooltip shows the value). The memory lasts for the editor session and is not saved.

Graph

Graph mode plots one or more curves y = f(x), each in its own colour, over a grid with labelled axes.

  • Add function adds a curve; type its expression of x in the row (sin(x), x^2 - 1, exp(-x^2), 2*x + 1). Each row has the curve's colour and a remove button; a mistake shows a red warning icon in the row (hover it for the message) and the other curves keep drawing. A graph without curves shows "Add a function of x below, e.g. sin(x)".
  • Curves are coloured in order: blue, red, green, amber, violet, teal, pink, then again.
  • Every function of the formula language works; graphs always use radians (sin(x) has its period at 2 pi).
DoTo
Drag (left, middle or right button)Pan the view
Mouse wheelZoom at the cursor
Shift + wheelZoom the x axis only
Ctrl + wheelZoom the y axis only
Double-clickReset the view (x from -10 to 10, y from -6 to 6)
HoverThe trace cursor: a vertical line with the value of every curve at that x
Zoom in / Zoom out buttonsZoom on the centre
Fit buttonFit the vertical range to the curves
Reset buttonReset the view

Curves are drawn only inside the plot area, never outside it (over the function list or the board around the calculator). They are sampled more finely where they bend, and break cleanly at asymptotes and gaps (tan(x), 1/x) and at the edges of their domain (sqrt(x), ln(x)), instead of drawing a vertical line across the plot.

Roots (where a curve crosses y = 0) and intersections of two curves are marked with dots; hover a dot to read Root or Intersection and its exact point.

The curves and the visible range are saved with the board. Each pan or zoom gesture is one undo step (recorded when you release the mouse, or a moment after you stop scrolling), and so is each change of the curve list.

Saved with the board

WhatSaved
ModeYes
History (last 50 lines) and the last expressionYes
Angle unit (DEG / RAD)Yes
Graph curves and visible rangeYes
MemoryNo (editor session only)

See Keyboard Shortcuts for the keys, and Formulas for every function.