Function Plotter

Type a mathematical function and see its graph plotted on an interactive canvas with axes and grid.

How to use

  1. Type a function of x using JavaScript Math syntax — for example Math.sin(x), x**2 - 3*x + 1, or Math.exp(-x*x).
  2. Set the x and y ranges to frame the part of the graph you want to see.
  3. Click "Plot". The function is evaluated at every pixel column and drawn as a continuous curve on the canvas.

About this tool

A function plotter takes a mathematical expression in one variable, evaluates it at hundreds of points across a range, and draws the resulting curve on a coordinate grid. This tool uses a canvas element with a drawn grid, axis lines and tick marks, and evaluates the expression using JavaScript's Math object — so you write Math.sin(x) for sine, Math.log(x) for the natural logarithm, x**2 for x squared, and Math.PI for π. The hat operator ^ works as a power (it is converted to ** internally).

The expression is evaluated at every horizontal pixel of the canvas — typically over a thousand points on a desktop screen — and discontinuities (like 1/x at x=0 or tan(x) at odd multiples of π/2) are handled by breaking the line when the value jumps to infinity. The y range controls the vertical viewport: set it wide enough to see the peaks and narrow enough that the curve fills the canvas. If the function returns NaN or Infinity at a point, the plotter simply skips it and starts a new line segment.

This is a teaching and exploration tool, not a graphing calculator. It plots one function at a time, does not compute intersections, derivatives or integrals, and does not support parametric or polar equations. For those, a full-featured tool like Desmos or GeoGebra is the right choice. What this page does well is let you type a quick expression and see its shape instantly, in your browser, with no account, no app and no dependency.

The formula

The function string is evaluated as JavaScript: new Function("x", "with(Math){return (expr)}"). Supported: sin, cos, tan, asin, acos, atan, log (natural), log2, log10, exp, sqrt, abs, ceil, floor, round, pow, PI, E.

Frequently asked questions

What syntax do I use?

JavaScript Math syntax: Math.sin(x), Math.cos(x), Math.log(x), x**2, Math.sqrt(x), Math.PI. The ^ operator is converted to ** (power).

Can I plot two functions?

Not in this version — it draws one function per plot. To compare, change the expression and note the shape.

Why is there a gap in the curve?

The function returns Infinity or NaN at those points — for example, 1/x at x=0 or Math.log(x) for x≤0. The plotter skips undefined points.

Is the expression safe?

The input is restricted to alphanumeric characters, operators, parentheses and dots. No arbitrary code execution is possible beyond the Math scope.

Does anything leave my browser?

No. The function is evaluated locally and the canvas is drawn in your browser. Nothing is transmitted.

Related tools

Long links? Shorten them for free

Vai.la turns any URL into a short link with click statistics, QR Code and your own biolink.

Vai.la is not responsible for how the tools are used or for decisions made based on their results.