Complex plot Real plot 2D plot

0

0

0

0

0

0

0

0

mobile mode (if off, f↓ and g→ labels can be clicked without the mode buttons)

horizontal mode

light mode (only works if browser supports changing CSS rules)

disable unit conversion buttons

disable time and date buttons

disable integer and prime buttons

disable a few obscure buttons

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:

- RPN mode with 8-level stack
- chain algebraic mode with parenthesis
- Memory for hundreds of values
- Elementary arithmetic
- Scientific mathematical functions, including hyperbolics, loggamma, Lambert W, erf, ...
- Complex numbers: a complex number is the most primitive type, treated and displayed as a single value.
- Two-variate statistic functions
- Stochastic functions (permutations, binomial, Stirling number)
- Number theoretic integer functions such as primes, greatest common divider, factorization, ...
- Matrices (including complex matrices): multiply, determinant, inverse, eigenvalues, FFT, ...
- Keystroke programming, with up to 26 independent programs, with conditions and loops
- Numerical integration, derivative, root finding, ... using programs as functions
- Several display modes: polar, fraction display, fix, sci, eng, ...
- Arbitrary number base from 2 to 16, with support for rational, real and complex numbers, and fractions, in any base.
- Computer scientific functions such as bitwise AND
- Common unit conversions
- Date and unix time math

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

The f↓ and g→ buttons only work in mobile mode (for small screens). In non-mobile mode, the individual labels of buttons can be pressed. f↓ accesses the bottom left function. g→ 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.

- 0-9: digits
- a-f: hex digits
- .: period
- numpad +, -, *, /: elementary operators
- numpad enter or =: enter/equals
- ^: power
- (: rolldown, paren open
- ): rollup, paren close
- _ (underscore): negate
- i: enter imaginary part. When choosing memory address, also serves as (I).
- l: enter polar part
- backspace: backspace
- esc: on/c
- u: undo
- y: x↔y
- t: add value to statistics registers
- h: hyp mode
- v: invert mode
- x: XEQ
- s: STO
- r: RCL
- m: matrix
- |: abs
- p: EE

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 following ones are available:

- hyp + cos, sin, tan: cosh, sinh, tanh
- hyp + acos, asin, atan: acosh, asinh, atanh
- hyp + sinc: unnormalized sinc (sin(x)/x) instead of normalized sinc (sin(x)/(pi*x))
- hyp + enter: enter 8 times in rpn, 10 times in alg (to fill up stack with a constant in RPN, or repeat last operation 10 times in ALG)
- hyp + Σx: get sum of y's (normally gotten with -4, RCL, (I))
- hyp + Σx²: get sum of y's squared (normally gotten with -5, RCL, (I))
- hyp + Σn: get sum of xy products (normally gotten with -6, RCL, (I))
- hyp + 10
^{x}: 2^{x} - hyp + log
_{10}: log_{2} - hyp + e
^{x}: φ^{x} - hyp + ln: log
_{φ} - hyp + √x: cube root
- hyp + x²: cube
- hyp + x!: gamma function
- hyp + INV + x!: inverse gamma function
- hyp + erf: erfc
- hyp + W: lower branch of LambertW
- hyp + DoW: day of year (1-365/366)
- hyp + →unix, ←unix: convert to/from seconds since 1 january 1. Does not take Julian calendar into account. This scheme is used by some databases and differs 62135596800 seconds from Unix time.
- hyp + i: binary operation which combines first and second operand into 1 complex number (rectangular)
- hyp + θ: binary operation which combines first and second operand into 1 complex number (polar, how angle is interpreted depends on angle mode)
- hyp + re: split complex number into real and imaginary part
- hyp + im: split complex number into modulus and angle
- hyp + npr: nearest prime
- hyp + ppr: prime counting function
- hyp + fact: is prime?
- hyp + gcd: Euler's totient function
- hyp + rand: large range positive or negative random value
- hyp + crand: random complex value with large range positive or negative real and imaginary parts
- hyp + ∫f: Integrate with custom precision (given as amount of steps, default is 100). Ternary operator, third operand is steps.
- hyp + Σf: Summation with custom step instead of 1. Ternary operator, third operand is step size.
- hyp + Πf: Product with custom step instead of 1. Ternary operator, third operand is step size.
- hyp + solve: solve in automatic range (no input values required), increasing range until a zero is found. Bails out if the range gets too big.
- hyp + MxN: get/set size in the order width, height rather than height, width.
- hyp + A
_{11}: Get/set element with indices in the order x (0-based), y (0-based) instead of y (1-based), x (1-based) - hyp + x↔y: mirror the top N values of the stack. N is entered itself, but popped before the mirroring. N must be between 2-7.
- hyp + x≠y: truncate towards zero
- hyp + ≤, ≥: floor/ceil of fractional number (for programming)
- hyp + <, >: binary left/right shift (for programming)
- hyp + -, +: min, max with 2 arguments (for programming)
- hyp + IF: ternary operator ?:
- hyp + IP: return subprogram index
- hyp + SEL: return selected program index
- hyp + 1/x: for matrix: Moore–Penrose pseudoinverse
- hyp + /: for matrix: left division (a/b = inv(b) * a) rather than right division (a/b = a * inv(b))
- hyp + dec: set to custom base (press 2-9 or A-F after this to choose numeric base from 2 to 15)
- hyp + mod: remainder instead of modulo division
- hyp + +/-: get sign (-1, 0 or 1, or z/abs(z) for complex values)
- hyp + rpn: toggle between 8-level and 4-level RPN stack
- hyp + ./,: enable/disable thousand separators
- hyp + polar: toggle between entry and classical rpn, in classical rpn the enter key puts newly typed input twice on the stack
- hyp + R→P: 3D carthesian to spherical
- hyp + P→R: spherical to 3D carthesian

- -1: parameter for statistical distributions, typically the sample size or a mean μ
- -2: parameter for statistical distributions, typically a probability of success or a standard deviation s
- -3 — -9: [reserved]
- -10: n
- -11: Σx
- -12: Σy
- -13: Σx²
- -14: Σy²
- -15: Σxy
- -16: Σx²y
- -17: Σxy²
- -18: Σlnx
- -19: Σlny
- -20: Σln²x
- -21: Σln²y
- -22: Σlnxy
- -23: Σxlny
- -24: Σylnx
- -25 — -29: [reserved]
- -30: numeric base (shown in that base when getting it, so expect to see "10" on screen in any base, as 10 means 16 in hex, 2 in binary, etc...)
- -31: the current angle step, e.g. 360 for degrees or 6.2831853071795 for rad
- -32: 1 if polar mode, 0 if regular mode (read-only)
- -33: 1 if fraction mode, 0 if regular mode (read-only)
- -34: 1 if mixed fraction mode, 0 if not (read-only)
- -35: 1 if comma is used as decimal seperator, 0 if point is used (read-only)
- -36: 1 if thousand separators are enabled, 0 if disabled (read-only)
- -37: the current 'fix' precision, or -1 if other mode is used (read-only)
- -38: the current 'sci' precision, or -1 if other mode is used (read-only)
- -39: the current 'eng' precision, or -1 if other mode is used (read-only)
- -40: 1 if rpn mode, 0 if alg mode (read-only)
- -41: the rpn stack size, 4 or 8 (read-only)
- -42: 1 if entry rpn, 0 if classical RPN (read-only)
- -43: instruction pointer
- -44: sub-program in which instruction pointer is (equals currently selected program, unless XEQ was called from within a program)
- -45: currently selected program index (0-9, 10 for A, etc...)

- 0-3: Normal memory for the user. For programs, separate from the user, and separate for the 26 programs. Use for internal temporary values without disturbing the user or other programs.
- 4-7: Normal memory for the user. For programs, separate from the user, but shared for the 26 programs. Use for internal communication between programs without disturbing the user.
- 0-9: The memory addresses used when pressing STO/RCL followed by a decimal digit
- 100: The memory address used when pressing STO/RCL followed by A (Memory A). Also matrix A.
- 200: Memory B. Also matrix B.
- 300: Memory C. Also matrix C.
- 400: Memory D. Also matrix D.
- 500: Memory E. Also matrix E.
- 600: Memory F. Also matrix F, the default output matrix.

In RPN, if you enter three values, then the order you entered them in is: "z, y, x". That means, you enter them in the opposite order than the expected "x, y, z". For that reason, for example, the power button is labeled "y^x" and not "x^y": this ensures you can enter that power in an intuitive order, first the base, then the exponent. However, for a few operators you must take care as the input is in opposite order compared to intuition: these are rectangular->polar, polar->rectangular, rectangular->spherical, and spherical->rectangular. For example as the input of rectangular->polar is x and y, you enter y first, then x. But most operations do have an intuitive order, e.g. for an integral you enter the start of the interval first, then the end. The smaller than operator is defined as "y < x". And the power operator was already described earlier.

In ALG mode, the naming is the same. But, as there is no reason to invert them, here you enter x first, then y, for rectangular->polar, spherical->rectangular, etc...

To view the result of a 3-result operation (that is, spherical<->rectangular), in RPN mode, just use R↓ 2 times to see all 3 results. In ALG mode, however, R↓ does not exist (it is open parenthesis instead). There is another way though: the second result can be seen with x↔y as in RPN. But the third result can be seen by first pressing 3, then HYP, then x↔y. That key combination mirrors the top 3 stack values, thereby bringing the 3th value to the screen.

The precision modes are:

- automatic mode (all): the default mode. To get this, press fix fix, or fix period. In this mode, it never shows redundant zeroes behind the point, shows the highest precision possible, and only uses exponential notation if the number wouldn't fit on screen otherwise. That is, only for very large numbers or numbers very close to zero. For example, the number 55555 is displayed as "55555", and pi is displayed as "3.14159265358".
- fix mode: fixed mode. This mode has a precision n that you need to choose. There are always exactly n digits shown after the decimal point, even if it are zeroes. For example for n=6, the number 55555 is displayed as "55555.000000", and pi is displayed as "3.141592".
- sci mode: scientific mode. This mode has a precision n that you need to choose. It always uses exponential notation, even for small numbers like 5. The mantissa always has 1 digit before the point and n-1 digits after the point, for a total of n digits. For example for n=6, the number 55555 is displayed as "5.55550e4", and pi is displayed as "3.14159e0".
- eng mode: engineering mode. This mode has a precision n that you need to choose. It is very similar to scientific mode, except that the exponent is always a multiple of 3 (so that it is similar to units of measurements where 3 is kilo, 6 is mega, etc...) The mantissa always has a total of n digits. For example for n=6, the number 55555 is displayed as "55.5550e3", and pi is displayed as "3.14159e0".

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:

- rect mode: 1 i2
- polar mode (radians): 2.236067977 L1.107148717
- polar mode (degrees): 2.236067977 L63.43494882

It is also possible to choose whether to use the dot or comma as decimal separator. Thousand separator can be enabled with HYP+./, and use the other character.

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.

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 f, g 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 1/X φ RCL 0 POW φ RCL 0 +/- POW RCL 0 * π COS * - MUL

More examples, all in RPN, all assume being in program mode with cleared program. These example are here because these formulas are not in the calculator itself due to being easy to program.

- Haversine: sin²(x / 2): 2, /, SIN, x²
- Gudermannian function: asin(tanh(x): HYP, TAN, ASIN
- Square super root, solution of a^a = x, ssrt(x) = ln(x) / W(ln(x)): ln, ENTER, W, /

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.

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.

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:

- matrix + +: add two matrices
- matrix + -: subtract two matrices
- matrix + *: multiply two matrices
- matrix + /: multiply the first matrix by the inverse of the second matrix
- matrix + 1/x: invert matrix
- matrix + +/-: negate each element of matrix
- matrix + conj: take element wise complex conjugate of matrix
- matrix + ||: determinant, result is a single number pushed to stack
- matrix + 7: transpose
- matrix + 2: frobenius norm
- matrix + x²: matrix multipled with itself

- matrix + sqrt: matrix square root
- matrix + exp: matrix exponential
- matrix + ln: matrix natural logarithm
- matrix + cos: matrix cosine
- matrix + sin: matrix sine
- matrix + x
^{y}: matrix raised to scalar power (any power, including complex or very high values) - matrix + EE: find eigenvectors and eigenvalues of matrix. The eigenvalues are stored in 1D column vector in memory register 600 (F), the eigenvectors in registers after that. The memory address of the eigenvalues is shown on screen, the other is behind x↔y. To see the other, press x↔y first, then RCL (I) to see height, then RCL Σ+ to see with and repeat RCL Σ+ to see each element.
- matrix + ∫f: calculate 2D FFT (discrete fourier transform) of the input matrix. It is the 1D FFT if vector. E.g. FFT of [[1 2][3 4]] gives [[5 -1][-2 0]].
- matrix + ∂: calculate 2D IFFT (inverse discrete fourier transform) of the input matrix.
- matrix + solve: Solve system of linear equations, with input matrix and input column vector

- matrix + enter: duplicate matrix to different location in memory, result stored at memory register of your choice (popped from stack) and on
- matrix + A-F: Puts memory address of memory button A-F on the stack (100 for A, 200 for B, ...). This allows easily using matrices in these memory locations. Note that the output matrix is always at F (600). You are free to use other memory locations than these for matrices, it is just for convenience.
- matrix + Σ+: Adds each element of the matrix to the statistics (matrix element for x, 0 for y)
- matrix + Σ-: Subtracts each element of the matrix from the statistics (matrix element for x, 0 for y)
- matrix + 0: set the matrix to an all-zero matrix (replaces the existing matrix, keeps its size)
- matrix + 1: set the matrix to an identity matrix (replaces the existing matrix, keeps its size, if non-square puts ones on the diagonal)
- matrix + IP: For debugging: get a representation of the matrix as a single number: NM.xxxxxx where NM is the size and x is the first non-0 digit of each element. E.g. matrix [[1, 2][3, 4]] would output 22.1234
- matrix + x↔y: swap two matrices in memory

- elop + *: Multiply a matrix with a scalar
- elop + /: Divide a matrix through a scalar
- elop + round: Round each matrix element to an integer
- matrix + elop + *: Element-wise product (Hadamard product)

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

More matrix examples (in alg mode):

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, Σ+.

autogenerated

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) 2011-2015 by Lode Vandevenne.