Mathjs Grapher Help



1. Introduction


Mathjs Grapher is a graphing calculator that plots mathematical functions (just like Desmos).

It can support complex numbers, and it is powered by the Math.js Javascript library.
It can also be just a calculator that can evaluate expressions with complex numbers.

To begin using the grapher, simply type in a mathematical expression in the large box (e.g. sqrt(x)).
This will plot a curve of y=sqrt(x).


The blue curve is the real part of y, and the red curve is the imaginary part of y.


You can pan and zoom in the graph by dragging and scrolling on the graph.
To reset the zoom, double-click the graph.
You can also set your own bounds by going to Settings with the gear icon in the top right.

If you type in a expression without using the variable "x", the expression will be evaluated and displayed in



2. Syntax


Since the parser is evaluated using Math.js, the parser is flexible. It accepts many variations of input.
However, since the RegEx of this grapher is basic, don't use the letter x in functions.
Instead of max(x,5), use min(-x,-5).
x is meant to be replaced with a value from minimum to maximum x in the graphing process.

Possible syntax:
5x = 5*x
x5 = x*5
sinx = sin(x)
xx = x*x = x^2
xxx = x*x*x = x^3
sinx^2 = sin(x)^2



3.1. Functions


Arithmetic:
add(...), subtract(x,y), multiply(...), divide(x,y), pow(x,y)

Trigonometry:
sin(x), cos(x), tan(x), sec(x), csc(x), cot(x)
asin(x), acos(x), atan(x), atan2(x,y), asec(x), acsc(x), acot(x)
asinh(x), acosh(x), atanh(x), asech(x), acsch(x), acoth(x)

Calculus:
exp(x), log(x,y), log2(x), log(x), log10(x)

Number theory:
floor(x,y), round(x,y), ceil(x,y), abs(x), lcm(...), gcd(...)

Bitwise functions:
bitAnd(x,y), bitOr(x,y), bitNot(x), leftShift(x,y), rightArithShift(x,y), rightLogShift(x,y)

Statistical functions:
min(...), mode(...), mean(...), median(...)
max is only compatible for numbers than the variable x due to the basic regex replacing every x with a number.

min(...) - smallest number
mode(...) - most frequently occurring number
mean(...) - geometric mean of all arguments
median(...) - the number or the mean of two numbers separating two halves of the array

Misc functions:
range(x,y,z) or x:y:z - creates a matrix of numbers from x to y in increments of z. y and z are optional
map(array,function) - applies a function to each item in an array or matrix. example: map([1,2,3],v=v^2) outputs [1,4,9]

There are much more functions in Math.js. Here is a detailed list.



3.2. Constants


pi, PI = 3.1415926535...
e, E = 2.7182818284...
phi (golden ratio) = 1.6180339887...
SQRT2 (square root of 2) = 1.4142135623...
i (imaginary number, sqrt(-1))
SQRT1_2 (square root of 1/2) = 0.7071067811...
tau = 6.2831853071...
More constants: LN2, LN10, LOG2E, LOG10E


4. Datatypes


The calculator can also handle other datatypes than numbers. It can also handle strings, arrays (matrices), functions and objects.

{} returns an empty object, {a:3, b:2} returns an object with two properties (a and b). You can access them using the property accessor ".", for example: {a:2,b:3}.a returns 2.

[] returns an empty array (matrix). [1,2,3] is a matrix containing the numbers 1, 2, and 3. Matrices can contain anything, even itself.

"" returns an empty string. "String" returns a string which says String. Strings can be indexed, concatenated and even styled.


5. Strings


Mathjs Grapher can handle strings. You can use quotation marks to denote a string, for example: "Hello World".

You can index letters in a string by putting in a number in square brackets []. For example: "My String"[1] returns M, "My String"[5] returns m, etc.

You can also index substrings using arrays. For example: "String"[3:6] is ring and "listen"[[3,2,1,5,6,4]] is silent.

You can also concatenate strings by using the concat(...) function. For example: concat("apple","banana") returns applebanana.

You can style strings by using HTML span tag. For example: "<span style='color:red'>Red Text</span>" returns Red Text.

Numbers and other data types can also be formatted as a string using the string(x) function.


6. Other Features


You can explore many other features by browsing the 50 built-in presets.