This page uses PEG.js to parse a Sketchpad expression string and convert it to both an equivalent javascript function and a MathML display of the expression. The page uses MathJax to display the expression.
The raw Sketchpad expression string should, except for object references, match the syntax displayed in the "calculate" dialog in Sketchpad. Object references are references to other sketchpad objects such as measurements, functions, or other calculations. These are designated the raw Sketchpad syntax with an '@' sign followed by a unique word composed of letters, digits, and underscores.
Function:
MFS:
MathML:
Raw HTML:
HTML:
Execution:
Result:
json:
Errors:
Description | Expression | Arguments | Expect | Value | Function | MFS | MathML | HTML | isSimple | unit |
---|---|---|---|---|---|---|---|---|---|---|
A constant | 5 | 5 | ||||||||
A constant | -5.25 | -5.25 | ||||||||
A reference | @a | {"a":{"uValue":4}} | 4 | |||||||
A variable | x | {"x":4} | 4 | |||||||
Special Constant | pi | 3.1416 | ||||||||
Special Constant | π | 3.1416 | ||||||||
Special Constant | e | 2.7183 | ||||||||
parentheses | (5) | 5 | ||||||||
Addition | 1+2 | 3 | ||||||||
Subtraction | 1-2 | -1 | ||||||||
Unary minus | -pi | -3.1416 | ||||||||
Unary minus | -(1+2) | -3 | ||||||||
Multiplication | 1*2 | 2 | ||||||||
Division | 1/2 | 0.5 | ||||||||
Exponent | 1^2 | 1 | ||||||||
Order of evaluation | 2*10^-1/4 | 0.05 | ||||||||
Order of evaluation | 3*10^2/4 | 75 | ||||||||
Order of evaluation | 2*3/5 | 1.2 | ||||||||
Order of evaluation | 2/3*5 | 3.3333 | ||||||||
Sine | sin(180) | 0 | ||||||||
Cosine | cos(0) | 1 | ||||||||
Tangent | tan(0) | 0 | ||||||||
Square Root | Arcsin(0.5) | 30 | ||||||||
Square Root | Arccos(0) | 90 | ||||||||
Square Root | Arctan(1) | 45 | ||||||||
Absolute value | abs(-2) | 2 | ||||||||
Square Root | sqrt(4) | 2 | ||||||||
Natural log | ln(2) | 0.6931 | ||||||||
Log base 10 | log(10) | 1 | ||||||||
Sign | sgn(-2) | -1 | ||||||||
Round | round(2.1) | 2 | ||||||||
Truncate | trunc(2.1) | 2 | ||||||||
A constant length | 5 cm | 5 | ||||||||
A constant length | 5 pixels | 0.1763 | ||||||||
A constant length | 5 in. | 12.6999 | ||||||||
A constant angle | 5 radians | 286.4789 | ||||||||
A constant angle | 5° | 5 | ||||||||
An equation | f(x) = x^2+2*x+3 | {"x": 10} | 123 | |||||||
An equation | y = x^2+2*x+3 | {"x": 10} | 123 | |||||||
An equation | g(y) = y^2+2*y+3 | {"y": 10} | 123 | |||||||
An equation | x = y^2+2*y+3 | {"y": 10} | 123 | |||||||
An equation | f(θ) = θ^2+2*θ+3 | {"θ": 10} | 123 | |||||||
An equation | r = θ^2+2*θ+3 | {"θ": 10} | 123 | |||||||
An equation | g(r) = r^2+2*r+3 | {"r": 10} | 123 | |||||||
An equation | θ = r^2+2*r+3 | {"r": 10} | 123 | |||||||
An equation | f(x) = @a*x^2+@b*x+@c | {"x": 4, "a": {"uValue": 1}, "b": {"uValue": 2}, "c": {"uValue": 3}} | 27 |