Paste from clipboard to calculator:
Paste and enter

Complex plot Real plot 2D plot

Inspect whole stack:
0
0
0
0
0
0
0
0

Options
mobile mode (if off, 2nd and 3rd labels can be clicked without the mode buttons)
horizontal mode

Manual

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Welcome to the scientific programmable JavaScript calculator!

JSCalc aims to be an as complete, convenient and orthogonal possible calculator that does not have text. Features:

Hover with the mouse over each sub-section of a button to see an explanation of what it does. These are not explained in this manual but there instead.

Each button has up to 4 functions. Press the sub-section of a button with the mouse to perform that function.

The 2nd↓ and 3rd→ buttons only work in mobile mode (for small screens). In non-mobile mode, the individual labels of buttons can be pressed. 2nd↓ accesses the bottom left function. 3rd→ the top right function. Both combined accesses the bottom right function.

To paste a number from clipboard to the screen, use the paste input field below the calculator. Making the screen itself an input field and pasting in there does not play out well because the JavaScript calculator engine won't always recognize you changed the screen value that way since you didn't use any calculator buttons. Seperating this away into a separate input field with dedicated button clears away all confusion for both the user and the calculator. The input field is designed for pasting (CTRL+V), if you try to type numbers in here you'll notice the numbers appear in the calculator screen instead, because the number keys are already shortcuts for the number buttons of the calculator.

Keyboard shortcuts

A totally different type of shortcut is that you can click with the mouse on the indicators above the display to toggle these modes as well (where applicable).

The Hyp Shortcuts

There are some functions available that aren't labeled on the keys. These use the hyp modifier, normally used to modify sin, cos and tan into sinh, cosh and tanh.

The following ones are available:

Statistics and special memory register indices

Note: The statistics indices are in the beginning of the negative ones. Lower negative ones provide access to several flags and running parameters. Positive memory addresses with extra meaning:

Differences with typical calculators

  • The = key is called "Enter" instead, even in algebraic (= non-RPN) mode.
  • In algebraic mode, almost all two operand (binary) operators use the same keystroke order as the "+", "-", etc... operators. E.g. to calculate the arbitrary logarithm, press x logyx y enter, or to calculate rectangular to polar, press x, r->p, y, enter (but since this operator has two instead of 1 result, after looking at first result press x<->y to see the second result).
  • It does not take operator precedence into account (so it's "chain algebraic"). Parenthesis are supported though.
  • In algebraic mode, pressing enter multiple times after doing a binary operator, repeats the last operation with the last second operand.
  • Complex numbers are one entity taking up a single register, not two separate values. A complex number is the most primitive value.
  • Any base from 2 to 16 is supported, and non integer or complex numbers can be represented in any base.
  • There is also an RPN mode
  • Due to the JavaScript implementation, the numbers calculated with are stored as binary internally, which unfortunately means sometimes numbers are displayed not exactly as you enter them (floating point errors).
  • There are ternary operators (taking 3 arguments), e.g. summation with start, end and step size. In RPN these are straightforward to enter. In ALG mode, to use a ternary operator TO with operands o1,o2,o3 (numeric values), press the buttons in the following sequence: o1, TO, o2, ENTER, o3, ENTER.
  • Differences with typical RPN calculators

  • In button names, x refers to the first value entered, y to the second. So the top stack value is not named 'x'.
  • For Rect to Polar conversion, X is entered first, then Y. For Polar to Rect conversion, r is entered first. This is done on purpose because this is more natural.
  • Programming uses 26 completely separate programs and no labels, instead of 1 program space in which all programs are together and identified with labels. When writing a program, a LBL instruction at the start and RTN at the end are not needed.
  • The stack is used for even more things than usual, e.g. which line to go to with GTO, which indirect memory address to load/save with (I), the truth value (0 or non-0) for IF, ...
  • There are 8 instead of 4 stack levels
  • Typing a number, then pressing enter, enters the value once. It does not duplicate it. As long as the value is being typed, it is not yet in the stack and enter finishes the typing and pushes it to the top of the stack.
  • Display modes

    This calculator supports a lot of display modes. The precision modes automatic, fix, scientific or engineering, can be combined with any numerical base, complex numbers in rectangular or polar notation, and fraction or floating point notation. Any combination of these is possible.

    The precision modes are:

    If the base is another base than decimal (base 10), everything works exactly the same, except it uses the amount of digits for that base. The base is used for everything, including the exponent, angles of polar complex notation, etc... However, in any base other than 10, 'p' instead of 'e' is used for the exponential notation (Because e is a symbol in some bases)

    E.g. the complex number that looks in decimal like 4.348606e23 i1.0072e23, looks in ternary: 1.211p1211 i1.021p1210, and in hexadecimal: 5.C15D84p13 i1.5540BAp13.

    For complex numbers, all the above rules are applies separately to the real and imaginary part. In fraction mode, the real and imaginary part, or modulus and angle part are also a separate fraction. Two modes are available for complex numbers: rectangular and polar. In rectangular mode, the real and imaginary part are shown, separated by the symbol "i" in the middle. This is different than mathematical notation, because here i is a separator! What is written as 1+2i in mathematics, is displayed as 1 i2 here. Or what is written as -5i in mathematics, is displayed as 0 i-5 here (so it is NOT i minus real 5, but, i multiplied by -5). In polar mode, the modulus is displayed first, then an "L" symbol which represents the "angle" symbol as it would look on a 7-segment LCD screen, and the angle. The angle's display depends on the currently angle modes, e.g. when using degrees it's in range -180 - 180, if it's radians it's in range -pi - pi, etc... For example:

    Programming

    This calculator is keystroke programmable. This means a program can be a sequence of keys automatically executed with just a single key press.

    There are 26 independent programs. To select a current program, press SEL, followed by 0-9 or A-F, or +,-,*,/,SIN,COS,TAN,EXP,SQRT,POW (The value 26 is not related to the alphabet). The currently selected program is the one edited by P/R, executed by R/S, and the one used by integrate, solve, etc... The other programs are unused and untouched, until they are selected by SEL. The XEQ button, however, allows to easily execute another program without selecting it. Because they are incompatible, RPN and ALG mode each have their own independend programs. So in reality there are twice as much programs. In ALG mode, you never see the programs of RPN mode, and vice versa.

    Entering a program

    To enter a program, go to program mode by pressing P/R. Then press all keystrokes in the correct order. Then press P/R again to go back to normal mode. If a program was already entered and you want to clear it, press PCLR before entering the new program.

    When entering a program, after each keystroke, it shows the current program step (line number) and a short letter code of the key on screen. The backspace button can be used to undo the last keystroke. The BST and SST keys move forwards and backwards in the program, allowing to view previous instructions and inserting new ones between there. Each key with a label or behind HYP has a short letter code, that is, functions behind 2nd, 3rd or HYP have their own short letter code and the modifier key is not programmed itself. However, other modifiers, such as MATRIX, are programmed as keystrokes and the key keeps its non modified short letter code.

    For example, to enter a program that calculates x², press P/R, then x², then P/R again to exit programming mode. To enter a program to calculate sinc(x), which is sin(x) / x, first clear the previous program with PCLR. For an RPN program press P/R, ENTER, SIN, x↔y, /, P/R. For an algebraic program to do the same (however it has to use memory due to no RPN stack), press P/R, STO, 0, SIN, /, RCL, 0, ENTER, P/R. Then, to try out the program, e.g. to calculate sinc(5), press 5, then R/S, and the result is shown (0.0174311485495 if angle mode is in degrees).

    Another example: The generalized fibbonaci number in RPN mode, 1/sqrt(5) * (φ^x - φ^(-x)*cos(pi * x). This program requires radians, so the first instruction is to enable radians. In programming mode, clear the program if it's not empty, then enter: RAD STO 0 5 SQRT INV φ RCL 0 POW φ RCL 0 +/- POW RCL 0 * π COS * - MUL

    Running a program

    To run a program, go out of program mode (press P/R if in program editing mode). Then, there are two ways to run the program: The R/S button runs the program from the current instruction pointer (ip) position till the end. The ip will usually be at 0: after running a program, or when editing a program and entering the last instruction last, the ip will be at 0. So in that case R/S simply runs the program from the beginning. However, if a program pauzed itself, or the BST/SST buttons were used during or after editing the program, the ip may be elsewhere.

    The other way to run the program is to use the XEQ button. This always runs a program from ip 0, and allows running other programs than the current one. After pressing XEQ, press 0-9 or A-F to select which program to run. E.g. if in "0" you made a program to calculate the error function, and in "A" you made a program to calculate sinc(x), press "XEQ 0" to calculate the error function, "XEQ A" to calculate sinc. Using XEQ does not change the selected program (the one that gets edited with P/R, ran with R/S, or used by integral, solve, etc...). The SEL button does that.

    Program Flow

    Apart from keystroke sequences, programs can also contain conditions, loops, etc...

    The IF instruction requires entering an END instruction later, and optionally an ELSE instruction. It can be used for branches, based on a condition. The IF conditions checks the current value on screen. If it's 0, the part between ELSE and END is executed. Otherwise, the part between IF and ELSE is executed (and it jumps after the END afterwards). Nested IFs are supported. Anything can be used as the IF condition: e.g. the test operators give 0 or non-0 as answer, so does the "prime?" function, and anything else you create can be designed to put 0 or 1 on top of the stack to be used by an IF. The l.and, l.or, l.xor and l.not allow doing logical operations on such booleans, e.g. to combine multiple conditions for an IF.

    The test instructions (equals, <, >, etc...) are binary operators that compare two numbers and give a boolean answer (0 or 1). This can then be used by the IF instruction.

    The GTO instruction goes to a certain line number. Whenever you enter an instruction in a program, its line number is shown. The line number to go to is the current top stack value (the value on screen). Normally, when a program runs, it goes sequentially from beginning to end (sometimes skipping parts based on IF instructions). With GTO, you can go to any line number. This can cause an infinite loop, to avoid that a condition can be added by putting the GTO in an IF. Because you may not easily know the line numbers while entering a program, designing it on paper first can be a good idea.

    GSB is the gosub instruction. It's similar to GTO, except that it remembers where it was. When later an RTN instruction is encountered, it goes back to where GSB was called. This allows creating functions. Up to 100 nested GSB calls are supported.

    Integration

    The definite integral of a function can be calculated. The function must be defined with a program. The integral itself is a binary operator: the two arguments it takes are the start and the end of the definite integral range. To calculate the integral from 100-200 of x², first enter the program x²: press PCLR if needed, then P/R, x², P/R. Then in RPN mode press 100 ENTER 200 ∫f. In algebraic mode, press 100 ∫f 200 ENTER. The result, 2333333.3333333, is shown.

    Summation and product

    Summation and product work exactly the same as the integration operator. Summation adds values in the range, with step 1 between each value. Product does the same but multiplies them. E.g. to multiply the number 1, 2, 3, 4, 5, you can press PCLR first to clear the program (now the program is empty and thereby represents the function "x". Nothing needs to be entered in the program). Then in algebraid mode press 1 Πf 5 ENTER, and the result, 120, is shown.

    Derivatives

    This works similar to integration, but it takes only one value instead of two: the value for which to show the derivative. For example, when f = x², to calculate f'(5), type: PCLR, P/R, x², P/R, 5, ∂. The answer, 10 (or approximate 9.99999) is shown. To calculate the second order derivative, use the ∂² button instead.

    Solve

    This finds a zero of the function represented by the program. This operator takes two arguments: the begin and end of the range to search in. If no zero is found inside that range, it returns NaN instead. E.g. to find a root of x - 5 in range -20 to 20, press (in algebraic mode): PCLR, P/R, -, 5, ENTER, P/R, -20, solve, 20, ENTER. The result, 5, is shown.

    Matrices

    For matrices, there's only one new button: "matrix". Pressing it, followed by another button, does a matrix operation.

    Some matrix operators store the result overwriting the input matrix. That is: negate, conj, transpose, make zero/identity matrix.
    Most other unary and binary matrix operators store the result in memory register 600 (F) and on.
    Any unary matrix operator with two results stores one result overwriting the input matrix, the other in memory register 600 (F) and on.
    Matrix operators that output a matrix display the memory address of the result screen (usually 600).
    Matrix operators that output a scalar simply display the scalar on screen.

    Supported operations are:

    Basic operations:

    Advanced operations: Memory/other operations: The elop button allows doing an element-wise operation between a matrix and a scalar. When pressing matrix first, then the elop button, it does an element-wise operation with the corresponding elements of two (or more) matrices. This works with any operator (multiplication, COS, erf, ...). But the ones most useful for matrices are listed here: When pressing hyp first, then the elop button, it does an eigenvalue decomposition to the matrix, then applies any operator to the diagonal matrix, and then recomposes the matrix. This allows doing arbitrary operations to the matrix. Some above matrix operators, like Matrix+COS, already do the same thing internally, but this allows doing even more such matrix operations, like taking the acos, LambertW or erf of a matrix.

    To use a matrix operator, instead of putting operands on the stack, you put a memory index pointing to each matrix on the stack.

    That register in memory, and the successive ones, represent the matrix. The matrix result of a binary operation will be stored by default at memory register 600 (the one accessible with RCL F), while the result of an unary matrix operation that doesn't alter matrix size, will be stored at the same location as where the input matrix was (overwriting the original).

    The user needs to make sure matrices are far apart enough in memory to not overlap (an NxN matrix consumes NxN+2 registers). For example to add two 2x2 matrices A and B, A can be stored at register 0 (to 5), B at register 6 (to 11), and the result will be by default in register 600 (to 605). However the convenient memory locations A-F (100, 200, 300, 400, 500, 600) can be used instead, these are far enough apart for most use cases.

    The format of a matrix in memory at register N is: at register N itself is the height of the matrix, at register N+1 the width. At the NxN next registers are all the values of the matrix, row by row. Because using the Σ+ after STO or RCL allows easily storing/reading from successive registers, entering and viewing matrices is easy. Matrices support complex numbers since the most primitive number value is complex and a complex number is stored in one register. E.g. to view the output matrix, first use RCL F, to see the height of the matrix. Then RCL Σ+ to see the width. Then RCL Σ+ to see the first value, and so on to see the next values.

    Here's an example of how to add the matrix [[1,2],[3,4]] and [[8,8],[8,8]] using nothing but keyboard shortcuts, in RPN or ALG mode (where s is STO, t is Σ+, r is RCL):
    enter first matrix at memory 100-105: 2 s a 2 s t 1 s t 2 s t 3 s t 4 s t
    enter second matrix at memory 200-205: 2 s b 2 s t 8 s t 8 s t 8 s t 8 s t
    add them (RPN mode): m a enter m b m + --> it should now show "600" on screen (the memory index where the result matrix starts)
    add them (ALG mode): m a m + m b enter --> it should now show "600" on screen
    view the result at memory 600-605: r f r t r t r t r t r t --> it should have shown 2, 2, 9, 10, 11, 12 on screen

    More matrix examples (in RPN):

  • To add a matrix [[1,2],[3,4]] to a matrix [[5,6],[7,8]], type: 2 STO A 2 STO Σ+ 1 STO Σ+ 2 STO Σ+ 3 STO Σ+ 4 STO Σ+ (matrix A done), 2 STO A 2 STO Σ+ 5 STO Σ+ 6 STO Σ+ 7 STO Σ+ 8 STO Σ+ (matrix B done) MATRIX A MATRIX B MATRIX +
  • To multiply a matrix [[1,2],[3,4]] with a scalar 5, type: 2 STO A 2 STO Σ+ 1 STO Σ+ 2 STO Σ+ 3 STO Σ+ 4 STO Σ+ (entering matrix done) 5 2ND ELOP *.
  • To take the element-wise product of matrix [[1,2],[3,4]] with matrix [[5,6],[7,8]], type: 2 STO A 2 STO Σ+ 1 STO Σ+ 2 STO Σ+ 3 STO Σ+ 4 STO Σ+ (matrix A done), 2 STO A 2 STO Σ+ 5 STO Σ+ 6 STO Σ+ 7 STO Σ+ 8 STO Σ+ (matrix B done) MATRIX A MATRIX B MATRIX 2ND ELOP *
  • To take the lambertw of matrix [[1,2],[3,4]], type: 2 STO A 2 STO Σ+ 1 STO Σ+ 2 STO Σ+ 3 STO Σ+ 4 STO Σ+ (entering matrix done) MATRIX A HYP 2ND ELOP W
  • To view the result of any of the above (always stored in F, aka 600): RCL F RCL Σ+ RCL Σ+ RCL Σ+ RCL Σ+ RCL Σ+.
  • More matrix examples (in alg mode):

  • To add a matrix [[1,2],[3,4]] to a matrix [[5,6],[7,8]], type: 2 STO A 2 STO Σ+ 1 STO Σ+ 2 STO Σ+ 3 STO Σ+ 4 STO Σ+ (matrix A done), 2 STO A 2 STO Σ+ 5 STO Σ+ 6 STO Σ+ 7 STO Σ+ 8 STO Σ+ (matrix B done) MATRIX A MATRIX + MATRIX B ENTER
  • To multiply a matrix [[1,2],[3,4]] with a scalar 5, type: 2 STO A 2 STO Σ+ 1 STO Σ+ 2 STO Σ+ 3 STO Σ+ 4 STO Σ+ (entering matrix done) 2ND ELOP * 5 ENTER.
  • To take the element-wise product of matrix [[1,2],[3,4]] with matrix [[5,6],[7,8]], type: 2 STO A 2 STO Σ+ 1 STO Σ+ 2 STO Σ+ 3 STO Σ+ 4 STO Σ+ (matrix A done), 2 STO A 2 STO Σ+ 5 STO Σ+ 6 STO Σ+ 7 STO Σ+ 8 STO Σ+ (matrix B done) MATRIX A MATRIX 2ND ELOP * MATRIX B ENTER
  • To take the lambertw of matrix [[1,2],[3,4]], type: 2 STO A 2 STO Σ+ 1 STO Σ+ 2 STO Σ+ 3 STO Σ+ 4 STO Σ+ (entering matrix done) MATRIX A HYP 2ND ELOP W
  • To view the result of any of the above (always stored in F, aka 600): RCL F RCL Σ+ RCL Σ+ RCL Σ+ RCL Σ+ RCL Σ+.
  • A column vector (e.g. for "solve") has a height of n and a width of 1, so to enter e.g. a 3D column vector [7,8,9] in memory address 100 (a), use: 3, STO, a, 1, STO, Σ+, 7, STO, Σ+, 8, STO, Σ+, 9, STO, Σ+.

    This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

    Copyright (c) 2012-2014 by Lode Vandevenne.