Calqit: an intelligent vectorized scientific calculator

Andrew M. Steane,
Exeter College, Oxford University
and Centre for Quantum Computing, Oxford University
2010

 Download (alpha)

Contents

  1. Quick start with no fuss
  2. Introduction
  3. Summary for experienced programmers
    3.1 Operator precedence
    3.2 Implied brackets, commas, ''
    3.3 Index vs. multiplication
    3.4 The use of backslash
    3.5 Functionals
    3.6 More on user functions
       3.6.1 Default values
       3.6.2 Globals
       3.6.3 Pass by reference
  4. Tutorial
    4.1 Functionals
    4.2 Physical data
    4.3 Array indexing
    4.4 Writing programs
  5. Syntax and function reference
  6. History

"Calqit" is pronounced with a hard q sound, as in "cal-kit" or "calc-it".

1. Quick start with no fuss

Calqit is currently distributed as a .zip file (for windows). Extract all the contents to some convenient place on your system, then double-click calqit.exe (you can find it in the explorer and put a shortcut on your desktop if you like). [If windows sends a warning such as "The publisher could not be verified, are you sure you want to run this software?" then simply click "yes". This warning indicates merely that your operating system has not been told to trust the program. You can update your configuration later to correct this.]

Once the program launches, enter (i.e. type in and finish with the "enter" or "return" key):
clear path
This is needed when you run calqit for the first time, but not after that.

Next enter:
help plot
or
?plot
after the prompt. You should see some help on the plot function. Towards the end are some examples. Double-click on the first example (just after the line "e.g."). You should see a plot appear, and also the related command will appear at the prompt.

Next, double-click one of the other examples, and see that a new graph appears.

Next, in the main calqit window, hit the up-arrow key. You should see the last command reappear. You can now change it if you like, and then enter it again using "enter" or "return".

Hopefully by now you get the main idea. However, I recommend you browse the documentation a little in order to learn some of the convenient notations such as // for fractions, \ for array indexing, := and ; for creating functions, etc.

That's it!

N.B. calqit is currently an alpha version, that is, useful but incomplete. Click for more info.

2. Introduction

Calqit (pronounced "calc-it" or "cal-kit") is a scientific calculator program, with an emphasis on ease of use. It brings together some of the more attractive features of products such as Mathematica and Matlab. Calqit is a numerical calculator, not a symbolic manipulator, but it offers a natural and concise language which gives it some of the feel of a symbolic manipulator. Here is a short example:

> # comments begin with '#' (as in Python)
> a=4                              # a simple assignment      
4
> b=6; c=2;                        # two commands on one line, semi-colon suppresses output
> (-b + sqrt(b^2 - 4 a c))/(2 a)   # note the implied multiplication
-0.5
> sin pi/2                         # you can often skip brackets too (see syntax rules below)
1
> x=[0:4, 7,11]                    # the vector (0,1,2,3,4,7,11)
0 1 2 3 4 7 11
> x.sum                            # this can also be obtained by sum(x)
28
> plot(exp(-x^2/2);x,-4,4);        # plot a function
>?plot                             # get help regarding the plot function

The main uses foreseen are quick everyday calculations, exploring and checking ideas for research, science teaching (lecture and class demonstrations) and the teaching of programming. The syntax rules have been designed to be reasonably natural and flexible:

> # Bracket freedom: sin(x) means the sine of x. So does sin x, sin[x], sin{x} and \sin{x}.
> cos pi, cos(pi), cos{pi}, cos[pi], \cos{pi}
-1 -1 -1 -1 -1
> e^2/(4 pi eps0 hbar c)              # many fundamental constants are pre-defined
0.00729735
> e^2//4 pi eps0 hbar c               # // means everything to the right is in the denominator
0.00729735
> t=0:3; cos^2(t) + sin^2(t)          # cos^n(x) means (cos x)^n
1  1  1  1
> rho = property('density','copper')  # look up a physical property in calqit's database
Density of copper: 8933 kg/m^3.
8933
> rho = property density copper       # same thing with a little less clutter
Density of copper: 8933 kg/m^3.
> x=[0:2,7,11]
0 1 2 7 11
> x.4                                 # the 4'th element of x (can also be written x(4) or x[4])
7  
> s = sum(x^n/n!; n,0:100)            # note the intuitive syntax for this sum
1 2.71828 7.38906 1096.63 59874.1
> log s                               # confirm that s was the series for exp(x)
0 1 2 7 11
> myfun(n,x) := (sin(x)/x)^n;         # user-defined function
> m=Me;                               # set m equal to mass of an electron
> ke(v) := (1/2) m v^2                # user-defined function using a global variable m
> qinteg(exp(-x^2);x,0,inf)           # can't remember an integral? get it here
0.886227
> 4 ans^2                             # ans refers to the previous answer
3.14159                     

calqit is

  1. small and powerful. calqit offers a complete programming language. The total footprint on disk is about 1 Mbyte. The start-up time is essentially immediate (i.e. limited by your disk or network speed).
  2. intelligent: it allows the user flexibility in syntax and does a good job of interpreting what is meant and displaying results in a useful way.
  3. vectorized: handles lists of numbers, vectors and matrices, strings, and some other data types such as stack, queue, list.
  4. fast: it has good performance on a number of speed tests. It is not as fast on low-level numerics as compiled Fortran or C, but it compares well with high-level programming languages such as Matlab and Python. It has a similar speed on many tasks and is significantly faster (by a factor 10 or more) on some.
  5. well-informed it possesses a database, containing a large number of physical constants, properties of materials, and scientific and mathematical formulae.

Overall, calqit offers a high-level language with an intuitive and flexible syntax, plenty of predefined constants, and a restricted range of types.

2011: alpha version
New software is commonly labelled alpha, beta, gamma, to indicate its state of development. alpha is a preliminary stage where the program is useful but incomplete. calqit is currently at alpha stage.

Strengths and weaknesses:

  • alpha-calqit should be regarded as a general purpose scientific calculator and a programming language. I have used it for data analysis and testing out ideas in theoretical physics; in some respects I prefer it to Matlab because of its concise syntax, but it must be admitted it is not nearly as wide-ranging.
  • There are currently some major omissions: complex numbers and multi-dimensional arrays, and three-dimensional graphics.
  • Also missing (but planned for future versions): special functions such as Bessel, ODE (Runga-Kutta), eigenvalues, bitmaps
  • Almost missing (=under development): keyboard input in user programs (getch, getkeyb functions).
  • Not fully tested: recursion in user-defined functions, access to mouse.
  • Some speed-ups are still to be implemented, and at present the language is function-based with almost no object-orientation.
  • It is easy to write small programs, e.g. to demonstrate some maths or science, or load and analyse some data. Larger programs will need a debugger. This is planned but not yet available.
  • 3. Summary for experienced programmers
    4. Tutorial
    5. Syntax and function reference

    6. History

    calqit evolved from an earlier program called "AndyCalc" that was developed on DOS and was restricted to scalar calculations. AndyCalc proved to be a convenient and popular tool in the Oxford University Ion Trap Quantum Computing research group, so it was decided to upgrade it for Windows. The new program was for a while called jCalc, then re-named to calqit in 2011. calqit can handle vectors and matrices as well as single numbers (scalars) and has a greatly expanded set of functions. Calqit development began in 2007 and progressed intermittently. A major revision was undertaken in 2009. During 2010 occasional additions and tweaks were made. The first version was released in 2011. At the time of writing (March 2011) most of the basic functionality is in place, but some syntax issues are still to be decided, and the set of numerical methods is incomplete.

    [top]
    17/10/2011