Function Plotter
Use this math graph maker to compare real functions of x on one 2D graph. Start with x^2, 1/x and sqrt(x), then change the expressions or the viewing range. Each curve has its own color and cursor reading.
- Functions
- 3
- x range
- -4 to 4
- Angles
- Radians
- Cursor
- x = 2, f1 = 4
- y range
- auto, -2 to 16
- f1 = 4.000
- f2 = 0.500
- f3 = 1.414
The window
The range along x is yours. The range along y follows the samples unless you set it, and a curve that leaves the window is cut at the edge rather than squashed into it.
Move the pointer across the graph to read the curves under it, or give the graph focus and use the left and right arrow keys: one sample step a press, ten with shift held, and Home or End for the ends of the range. Between 32 and 4,000 even steps across x, which is one more value than that counting both ends, and the page adds its own points between them where a curve turns sharply.
Three cases, worked here
Each line is computed by the same code the graph uses, on the range this page opens with.
- Each function is worked out at 801 evenly spaced values of x from -4 to 4, and neighbouring points are joined with straight lines.
- 30 more points were worked out between samples where a curve turns sharply or leaves the window.
- The y window is set from the samples: twice the upper quartile of each curve's size, rounded out to -2 to 16, so one value beside an asymptote cannot flatten the rest.
- sin, cos and tan take x in radians, so a full turn is 2pi.
- The drawing is cut in 1 place where samples have no value, leave the window or still change sharply at the refinement limit, and nothing is drawn across those gaps. A break alone does not prove a discontinuity.
What an expression may contain
x is the input. These functions and constants are the whole vocabulary: a name that is not here is an error rather than a surprise, because the text is parsed here and never run as code.
- sinsine
- coscosine
- tantangent
- sec1 / cos
- csc1 / sin
- cotcos / sin
- asininverse sine
- acosinverse cosine
- ataninverse tangent
- sinhhyperbolic sine
- coshhyperbolic cosine
- tanhhyperbolic tangent
- sqrtsquare root
- cbrtcube root
- absabsolute value
- expe to the power
- lnnatural log
- loglog base 10
- log2log base 2
- floorround down
- ceilround up
- roundround to the nearest whole number
- sign-1, 0 or 1
- modremainder of a divided by b
- minthe smaller of two values
- maxthe larger of two values
- pihalf a turn in radians
- taua full turn in radians
- ethe base of the natural log
- Only the listed functions are available: the expression is read by a parser on this page, never run as code. The list is sin, cos, tan, sec, csc, cot, asin, acos, atan, sinh, cosh, tanh, sqrt, cbrt, abs, exp, ln, log, log2, floor, ceil, round, sign, mod, min, max.
- A feature narrower than the gap between two samples can be missed. Raise the sample count to look closer.
- It plots y against x and reports the samples. It does not solve equations, differentiate, or find where two curves meet.
- Each curve is capped at 12,000 worked points, which is what keeps a hard expression from hanging the page.
Common questions
- How do I plot a function?
- Type the right hand side in an f1 to f6 field: the y = is already there. The page opens over x from -4 to 4. Use the controls under the graph to change the x range, y range, angle unit, sample count or Cursor x. Samples accepts 32 to 4,000 even steps across x; the default is 800 steps, or 801 values including both ends.
- How do I graph a line from its slope and intercept?
- For y = mx + b, replace m and b with numbers and enter the right hand side. A slope of 2 and y intercept of 1 gives 2x + 1. At Cursor x = 2, that line reads 5.000. This draws a line from the equation you supply; it does not fit a line to data points.
- Can I graph a quadratic function?
- Yes. Enter x^2 for the basic parabola, or an expression such as x^2 - 4x + 3. That quadratic reads 0.000 at x = 1 and x = 3, and -1.000 at x = 2. The graph samples the curve; it does not calculate roots or the vertex as a separate result.
- Why does my graph have a gap in it?
- Undefined values and samples outside the y window are omitted from the drawing. Sharp changes still unresolved at the refinement limit also split the curve, even on a steep continuous function. A break alone does not prove a discontinuity or its exact position. For 1/x over -4 to 4, the two pieces stay apart at zero; sqrt(x) is blank for negative x. Very narrow features can still be missed.
- What can I type in a function?
- Use x, numbers, brackets and + - * / ^. The 26 functions are sin, cos, tan, sec, csc, cot, asin, acos, atan, sinh, cosh, tanh, sqrt, cbrt, abs, exp, ln, log, log2, floor, ceil, round, sign, mod, min and max. The 3 constants are pi, tau and e. Multiplication can be omitted in forms such as 2x, 3 sin(x) and 2(x + 1). min, max and mod take two arguments, such as max(0, x). Each expression may contain up to 240 characters. Unknown names and unsupported characters produce an error.
- Is x measured in degrees or radians?
- Radians is the default. In Degrees mode, sin(x) reads 1.000 at x = 90; in Radians mode it reads 0.894 there. Inverse trigonometric functions return the chosen unit too: asin(1) is 90 in degrees and about 1.571 in radians. The graph, readout and exported image label the angle unit.
- Can I plot periodic functions?
- Yes. Enter sin(x) or cos(x) and set x from -2pi to 2pi in Radians mode to see two periods. You can also enter a real expression such as sin(2x) + cos(x). The page draws the expression over your chosen range; it does not infer or report its period.
- How many functions can I graph at once?
- Up to six functions share the same axes. A new empty slot appears as you fill the last one. Each slot keeps its color, so clearing f2 does not recolor f3. An invalid expression is reported on its own row while valid curves remain visible.
- How do I graph a step or Heaviside function?
- Enter (1 + sign(x))/2 for a unit step with the half-height convention: it is 0 for negative x, 1 for positive x and 0.5 at zero. Set Cursor x to 0 to read that boundary value. The parser accepts this expression, but has no function named heaviside or step.
- How do I graph a ramp or a rectangular pulse?
- Enter max(0, x) for a unit ramp: it is 0 for negative x and equals x for positive x. For a rectangular pulse, enter (sign(x + 0.5) - sign(x - 0.5))/2. This pulse is centered at zero with width 1 and height 1; it is 0 outside the pulse and 0.5 at both edges. Use Cursor x to inspect the edge values. There are no functions named ramp or rect.
- Can I enter a general piecewise function?
- Expressions such as abs(x) and max(0, x) work, but the parser has no conditional branches or comparison operators. It cannot accept a list of formulas with conditions such as x < 0. Arbitrary piecewise definitions need a different input format.
- How does the page choose the y range?
- Auto uses the bulk of each curve's samples and rounds the combined range outward. This keeps large values near a pole from setting the whole scale. The starting three curves use y from -2 to 16. Choose Set it to enter the bottom and top of the y window yourself.
- How do I read a value off the curve?
- Move the pointer across the graph, tap it, or enter a number or constant expression such as pi/2 in Cursor x. The readout shows every valid curve at that x. With the graph focused, Left and Right move one sample step, Shift moves ten steps, and Home and End reach the range endpoints. An undefined reading says no value. A cursor outside the x range still gives readings but has no marker on the graph.
- Can I save the graph?
- SVG saves each drawn curve segment as a vector path. PNG saves a 1440 by 880 image. Both include the current functions, axes, angle unit and cursor when it is visible. Copy puts the functions, ranges, angle unit, sample count and cursor readings on the clipboard as text. Downloads and clipboard access depend on your browser's permissions. If PNG creation fails, try SVG.
- What kinds of plots does this page support?
- This page plots real y = f(x) expressions on Cartesian x and y axes. It has no complex-number, 3D, polar, parametric or general implicit-equation mode. For example, x^2 + y^2 = 1 cannot be entered as an implicit circle.
- What will this page not do?
- It does not solve equations, differentiate, find curve intersections or prove properties of a function. It uses floating-point values and a bounded number of samples, with up to 12,000 sample and refinement evaluations per curve. Expressions are parsed locally rather than executed as code. The page does not control a physical plotter or printer.
Expressions are read by a parser written for this page and never run as code, so only the listed functions exist. The curve is sampled and refined where it turns sharply, so it is a drawing built from samples rather than an algebraic solution: a pole is left as a gap instead of a vertical line, a point outside the domain is left blank, and the angle unit is the one labeled on the graph.