Canvas Calc

by Jacob Welsh
+ - * / mod ^
(-) 1/ ^2 sqrt exp ln
floor ceil abs sign ! log
sin cos tan 7 8 9
asin acos atan 4 5 6
sinh cosh tanh 1 2 3
asinh acosh atanh - 0 .
pi e rand E
x θ t
Clear:

Canvas Calc requires a browser with HTML5 Canvas support.




Zoom:

Help

Canvas Calc uses postfix, also known as reverse Polish notation: operators go after operands.1 When a number is read, it is stored in memory on a stack ("pushed"). Multiple numbers may be given sequentially, separated by spaces; each is pushed on top of the stack. Operators remove ("pop") their operands from the top of the stack and push the result. Each takes zero, one, or two operands, corresponding to its color coding. The number remaining on top of the stack after all input is processed is the result. Some examples:

Standard RPN
3 - 2 3 2 - 3 -2 +
sin(-x) x -1 * sin x (-) sin
1/x 1 x / x 1/
1 + 2 × 3 2 3 * 1 + 1 2 3 * +
(1 + 2) × 3 1 2 + 3 * 3 1 2 + *
223 2 2 3 ^ ^
(22)3 2 2 ^ 3 ^

The special symbols x, θ, and t push the independent variable of a standard, polar, or parametric plot, and may be used only in the respective plot input fields.

Calculations are done using JavaScript numbers, which use double-precision floating-point format. This is comparable to 15 decimal places of precision, but some calculations will not yield round decimal results where you might expect.2

Canvas Calc should support any standards-compliant HTML5 web browser, such as Firefox, Chrome, Safari, or Internet Explorer 9. It runs entirely on the client side and uses local storage for persistence.3 It is free software and can be downloaded for offline use; see the source page for details.

This is version 100K.4


[1] While this may be confusing at first compared to standard infix notation, it allows any expression to be written unambiguously without parentheses or implicit order of operations (precedence and associativity). It also simplifies implementation.

[2] Just as, for example, 1/3 × 3 will not yield exactly 1 in finite decimal arithmetic.

[3] Depending on your browser, you might need cookies enabled for local storage to work (though unlike cookies, nothing is sent to the server). Up to 500 lines of history are saved.

[4] Kelvin versioning: counts downward, approaching absolute zero, by which point it will be finished.