*the calculator reimagined*

Every desktop operating system and phone has a calculator app. They reproduce a desktop calculator, but often no more. **calQ **tries to take a step beyond this, exploiting more of the possibilities of being on a computer screen, whilst retaining the simplicity of a normal four function calculator when the user doesn’t want any more functionality. In particular, you can see past calculations, name and edit them, and then, if you wish, export your calculations as a spreadsheet or JavaScript function.

**calQ** tries to bridge the gap between calculator calculations and more expressive applications such as spreadsheets and programming languages. It is designed to be part of wider ecosystem of applications that help you to move as seamlessly as possible from just typing in numbers and adding them up to more complex calculations.

You can play with **calQ** at: https://datatodata.com/calq/

Here is **calQ** in action – it is a standard four-function calculator, with buttons to press emulating a hand-held calculator.

You can type formulae in and if you start by typing an operator (+,–,x,/) it is assumed to build on the last calculation, as in most calculators.

However, in addition there is a virtual `till roll’, like a retro office calculator. This keeps track of all your past calculations, showing both the values of each step and the sum you entered to get it.

There is no explicit memory function, because all the past calculations are always available on the till roll. If you want to include the result of a past calculation, you simply scroll the till roll to the relavant lien and click it.

Note here the past step appears as @1 (step 1) in the half written formula line “45 + @1”, although the value of @1 is shown in the running display, just as it would if you had typed it.

## More complex example

Let’s look at a slightly more complicated example. Do you remember high school physics and working out the trajectory of a ball?

Here’s a sketch diagram, the sort of thing you’ll have had in your school books.

Assume you have been given the horizontal and vertical speeds (u and v) and want to work out how far the ball gets in each direction after a time t. The horizontal direction is easy (ignoring air resistance), u*t, but the vertical height has to take into account gravity (g) as well.

You now start to calculate these for the values on the sketch diagram entering 50 m/s each for u and v, and the3 seconds for t).

You then work out the horizontal distance travelled (x). Recall you can get the values by clicking the steps on the till roll.

So, the formula you want is the first line of the till roll (horizontal speed, u, 50) times the third line (time, t, 3). This gives a distance of 150 metres.

So, far this is not unlike an ordinary calculator.

## Naming

However, it is hard to keep track of which number is which. Happily **calQ** allows lines to be names.

Here the first line is being named ‘u’ as it is in the diagram. The following steps can be named too (v and t).

Names can be simple letters, or short phrases such as “monthly sales”

See how the names now appear in the formula for step @4 on the till roll (u * t) rather than the step numbers (@1 * @3)

Here the vertical height is also calculated.

Note how the formula lines, can also be named. Here step @6 (v*t-g*t*t) has been named ‘y’ as in the diagram.

## Editing

The entries of the till roll can be edited. here step @3, the time, is being changed to be 4 seconds

See how following steps that used step @3 (t) have also updated, rather like a spreadsheet,

## Exporting

Having done the calculation, you may want to save it for later.

In some ways this is rather like a simple spreadsheet and one of the ways to save the output is a CSV file that can be read into Excel or other spreadsheets.

Here is the CSV in Excel.

See how **calQ** has created both the Excel formulae and also a column with the more readable text version of the formulae.

It is also possible to export as a JavaScript function.

In this case you can choose which variables you want to be used as function parameters and which as outputs.

Note how **calQ** is doing a lot of ‘heavy lifting’: the example values from the calculation are used as defaults for the parameters; although ‘g’ wasn’t chosen as a parameter, it is included as a constant; and because two return values were chosen, these are being returned as a object with named fields.