Grapher syntax reference
The complete reference for grapher expressions and note graph blocks, with examples of every kind of plot.
The grapher reads the same plain notation you would type into a calculator. This page is the full reference: the kinds of plot, how expressions are parsed, and every function and constant. The same syntax is used inside notes in graph blocks.
Kinds of plot#
The grapher decides what to draw from the shape of what you type.
| You type | Plotted as | Example |
|---|---|---|
An expression in x | x^2 - 3x | |
y = an expression in x | y = e^-x sin x | |
x = an expression in y | x = y^2 - 2 | |
An expression in y only | y^2 - 2 | |
An equation in x and y | Implicit curve | x^2 + y^2 = 9 |
An inequality in x and y | Shaded region | y < 2x + 1 |
r = an expression in θ | Polar curve | r = 1 + cos θ |
(x(t), y(t)) | Parametric curve | (cos t, sin 2t) |
(a, b) with numbers | Point | (2, 3) |
A letter = a number | Slider | a = 2 |
Each row holds one expression with at most one =, <, >, <= or >=. A double inequality such as 1 < x < 3 needs two rows.
Functions of x#
Write the right-hand side on its own or with y = in front. Both of these plot the same curve.
x^3 - 3x + 1
y = x^3 - 3x + 1When you paste LaTeX, a leading f(x) = (or g(x) =, h(x) =) is turned into y =. Typed directly, write y = instead. Functions of are plotted sideways with x = …, or by typing an expression in y alone:
Implicit equations#
Any equation involving both x and y is drawn as an implicit curve, so circles, ellipses and curves that are not functions all work.
An expression with both x and y but no = is ambiguous, so the grapher asks you to write it as an equation, such as x^2 + y^2 = 4.
Inequalities#
Use <, >, <= or >= (or ≤ and ≥). The region where the inequality holds is shaded. Strict inequalities draw a dashed boundary; <= and >= draw it solid.
Inequalities in one variable, such as x > 1, shade a half-plane.
Polar curves#
Use θ for the angle, or type theta instead. The curve is drawn for .
An expression in θ alone, without r =, is also drawn as a polar curve.
Parametric curves#
Write a pair (x(t), y(t)) that uses t. The curve is drawn for .
To cover a different range, scale t inside the expressions: (2t, 4t^2) covers .
Points#
A pair of numbers is a point, drawn as a dot labelled with its coordinates. Coordinates can be expressions such as (pi/2, 1), and they can use sliders, so (a, a^2) moves along a parabola as you drag a. Points cannot depend on x or y.
Sliders#
A row of the form letter = number defines a slider. The value can be any constant expression, such as k = pi/4; once you drag the slider, the row shows the number. Any other letter used in an expression gets a slider automatically, starting at 1.
a = 2
y = a sin(x - b)Slider names are single letters other than the reserved letters below, upper or lower case, or a letter followed by digits such as a1 or k2. Because a letter followed by digits is always read as one name, write 2x rather than x2.
Reserved letters#
| Letter | Meaning |
|---|---|
x, y | Cartesian coordinates |
t | Parameter for parametric curves |
θ (or theta) | Angle for polar curves |
r | Radius for polar curves |
e | Euler's number, |
Everything else is free to use as a slider. Function names and the constants pi and tau are read as themselves, not as sliders.
How expressions are read#
The parser follows the conventions you use on paper.
| Rule | Example | Read as |
|---|---|---|
| Multiplication can be implied | 2x, 3(x + 1), x(x - 2) | , , |
| Adjacent letters multiply | ab x | |
Powers with ^ or ** | x^2, x**2 | |
| Powers group to the right | 2^3^2 | |
A minus sign is allowed after ^ | e^-x | |
| Functions can skip brackets | sin x, sin 2x, ln x^2 | , , |
| Powers of functions | sin^2 x | |
| Inverse functions | sin^-1 x, cos^-1 x, tan^-1 x | , , |
| Absolute value | abs(x - 1) or |x - 1| | |
| Multiplication signs | *, ·, × | |
| Division | / | 1/2x is |
A function written without brackets takes everything up to the next +, −, * or /. So sin x cos x is read as . Write sin(x) cos(x) or sin x * cos x when you mean the product.
A power takes only what comes straight after the ^: one number, letter, function or bracket, with an optional minus sign. So e^2x is and e^-2x is . Write e^(2x) when the whole product is the power.
Function names and constants are recognised even when run together with other letters, so sinx is and 2pix is . This stops working once a digit is in the run: sin2x is read as a single slider name, so write sin 2x. When in doubt, add a space or brackets.
Numbers can be written as 3, 0.25, .5 or in standard form, 1.5e3. Unicode −, ≤, ≥, ·, ×, π, τ and θ are all accepted.
Constants#
| Name | Value |
|---|---|
pi, π | |
tau, τ | |
e |
Functions#
All trigonometric functions use radians.
| Function | Meaning |
|---|---|
sin, cos, tan | Sine, cosine, tangent |
sec, cosec (or csc), cot | Reciprocal trigonometric functions |
arcsin, arccos, arctan (or asin, acos, atan) | Inverse trigonometric functions |
sinh, cosh, tanh | Hyperbolic functions |
ln | Natural logarithm, |
log, lg, log10 | Logarithm base 10 |
log2 | Logarithm base 2 |
exp | |
sqrt, cbrt | Square root, cube root |
abs | Absolute value, |
floor, ceil, round | Round down, up, or to the nearest integer |
sign | , or according to the sign |
min(a, b), max(a, b) | Smaller or larger of two values |
mod(a, b) | Remainder of , always non-negative |
fact(n) | , extended to non-integers by the gamma function |
gamma(z) | The gamma function, |
nCr(n, r) | Combinations, |
nPr(n, r) | Permutations, |
For logarithms in another base, use the change of base: is ln x / ln 3.
Examples#
| Goal | Type |
|---|---|
| A quadratic and its roots | y = x^2 - x - 6 (hover the crossings) |
| A modulus graph | y = abs(2x - 3) |
| Exponential decay | y = 100 e^(-0.2 x) |
| A transformed trig graph | y = 3 sin(2(x - pi/4)) + 1 with the π toggle on |
| A circle with centre , radius 3 | (x - 2)^2 + (y + 1)^2 = 9 |
| The region above a line and below a curve | y > x and y < 4 - x^2 on two rows |
| A tangent with a moving point | y = x^2, y = 2a(x - a) + a^2, (a, a^2) |
| The binomial coefficients as points | (2, nCr(6, 2)) |
| Simple harmonic motion | y = A cos(w x) with sliders A and w |
Graph blocks in notes#
Notes draw figures with a ```graph fenced block: one instruction per line. Any grapher expression can be a line, plus a few instructions for framing the figure. Blank lines are ignored and lines starting with # are comments.
| Instruction | Effect |
|---|---|
view xmin xmax ymin ymax | Set the visible window. Defaults to view -6 6 -4 4. |
rad | Label the x-axis in multiples of π |
y = … or any expression | Plot it, exactly as in the grapher |
(x0, y0) -- (x1, y1) | Draw a line segment |
(x0, y0) -> (x1, y1) | Draw an arrow, with the head at the second point (→ also works) |
fill a b y = f(x) | Shade between the curve and the x-axis for |
a = 2 | Fix a constant used by other lines (no slider is shown in a note) |
Numbers in view, fill and coordinates can be expressions such as pi, pi/2 or 2pi. In view and fill each number must be written without spaces, so use pi/2 rather than pi / 2. Segments and arrows need a space either side of -- or ->. A fill only works with a curve of the form .
Every line that draws something, or sets a constant, is listed under the figure as its caption, so readers can see exactly what is drawn. Figures in notes do not show points of interest; choose Open in grapher to explore them.
```graph
view 0 2pi -1.5 1.5
rad
y = sin x
y = cos x
fill 0 pi/2 y = sin x
(pi/4, 0) -- (pi/4, 0.7071)
```That block draws this:
The window is padded slightly and widened to fit the figure's shape, so curves never touch the frame. Lines that cannot be plotted are reported by pnpm notes:check and shown under the figure, so a broken graph is never silently empty. See Note format for when to use a graph and when to draw a diagram.