MathsGraphing & Visualization

Equation Graph
generator.

Plot up to three functions of x and see every zero, peak and crossing as you type.

How it’s worked out

You type a rule y = f(x), and the tool works out y at hundreds of evenly spaced values of x across the graph. It joins those points into the curve. Where f(x) has no real value, such as ln(x) for x of 0 or less, it leaves a gap.

Zeros. A zero is an x where the curve meets the x-axis, so f(x) = 0. The tool splits the window into 2,000 equal steps and looks for a step where the sign of f flips. If f(a) and f(b) have opposite signs, the curve must cross zero between a and b:

f(a)f(b)\displaystyle f(a)\,f(b)<0\displaystyle {}< 0

It then tests the middle of that gap and keeps the half where the sign still flips. This is the bisection method, and each round halves the gap:

m\displaystyle m=a+b2\displaystyle {}= \frac{a + b}{2}
  • a and b are the two ends of the gap, one step apart at the start.
  • m is the midpoint. If f(m) has the same sign as f(a), m becomes the new a; if not, it becomes the new b.

After 80 rounds the gap is far smaller than any digit you can see. A sign flip only counts as a zero if f is close to 0 at the end, which throws out the jumps of tan(x) at its asymptotes.

Crossings. Two curves cross where f₁(x) = f₂(x). That is the same as asking where the gap between them is zero, so the tool runs the zero search on

d(x)\displaystyle d(x)=f1(x)−f2(x)\displaystyle {}= f_1(x) - f_2(x)

Turning points. A sample that is higher than both neighbors marks a peak (a local maximum); lower than both marks a dip (a local minimum). Golden-section search then narrows each one down, much as bisection does for zeros.

The y range. When you leave it on Fit the curves, the window covers the middle 94% of the sampled y values (the 3rd to the 97th percentile) and stretches to the true top and bottom when they are not far beyond. A single huge value near an asymptote cannot squash the rest of the graph flat. For tan(x) on −2π to 2π the largest sample is about 1.6331 × 10¹⁶, yet the window runs from −11.04 to 11.04, so you still see the S-shaped branches.

Worked examples

Two signals a quarter turn apart

Lena is checking two AC signals in a lab, one shaped like sin(x) and one like cos(x), over two full cycles from −2π to 2π. She wants to know when they are equal.

The graph shows 4 crossings, at x = −5.4978, −2.3562, 0.7854, 3.927. Those are π4+kπ\tfrac{\pi}{4} + k\pi for whole numbers k. Every crossing sits at height ±0.7071, which is 22\tfrac{\sqrt{2}}{2}. At x = 2.5 the trace gives sin 2.5 = 0.5985 and cos 2.5 = −0.8011. Sine has 5 zeros in the window and cosine has 4.

Open this example in the tool

A bakery’s break-even points

Omar sells cookies by the dozen. His weekly revenue for x dozen is −0.5x² + 30x dollars, because he has to drop the price to sell more. His costs are $160 a week plus $6 a dozen, so 6x + 160. He plots both for x from 0 to 50.

The curves cross at x = 8 and x = 40. Between those two points revenue is above cost, so he makes a profit. Below 8 dozen or above 40 dozen he loses money. Revenue peaks at x = 30 dozen with $450, where the cost line is at $340.

Open this example in the tool

When coffee cools to 60 °C

Jess pours coffee at 90 °C in a 20 °C room. A simple cooling model gives its temperature after t minutes as 20 + 70e−0.05t. She wants to drink it at 60 °C, so she draws the flat line y = 60 as a second function, with x standing for t from 0 to 60.

The two curves cross at t = 11.19 minutes. The model starts at 90 °C and never reaches the room temperature, so the cooling curve has 0 zeros. After 10 minutes the trace shows 62.46 °C.

Open this example in the tool

Reading your result

The big number is the selected function at the trace x. Drag the brass point, use the trace slider, or type an x to move it. If it says undefined, the rule has no real value there, for example √x for a negative x.

Zeros are the x-intercepts: where the curve meets the x-axis. Turning points are the local peaks and dips. A peak is a local maximum and a dip is a local minimum, as defined in Stewart's Precalculus, section 2.3. They are local because a higher or lower value may sit outside your window.

Crossings are the points both curves share. In a word problem they are usually the answer: break-even, the moment two prices match, or the time a quantity reaches a target you drew as a flat line.

The counts only cover your window. sin(x) has 5 zeros between −2π and 2π but infinitely many in all. Widen the window, or use Zoom out, to check for more.

Asymptotes. Where a curve shoots off to infinity, such as tan(x) at ±π/2, the search steps over the jump instead of counting it. On −π to π it lists 3 zeros (−3.1416, 0, 3.1416) and no turning points, because tan(x) rises all the way from one asymptote to the next; on −3.1 to 3.1 it finds the one real zero, 0.

Common mistakes

  • Using degrees. The trig functions take radians. sin(30) gives −0.988, not 0.5. For degrees write sin(30π ÷ 180), which gives 0.5, and set x in plain numbers from 0 to 360.
  • Losing a minus in a power. −x² means −(x²), which is never positive. If you mean (−x)², put the brackets in.
  • Putting too much under a fraction. In the math field, typing / starts a stacked fraction, and everything you type next goes on the bottom. Typing 1/2x gives 1 over 2x, which is 0.125 at x = 4, not half of x (2). Press → after the 2 to leave the fraction, then type x.
  • A window that is too narrow. x² − 10x + 21 has zeros at 3 and 7, so a window from −5 to 5 shows only one of them.
  • Expecting a zero where the curve only touches. x² meets the x-axis at 0 without crossing it, so there is no sign change to find. The turning point list still shows the dip at (0, 0).
  • Trying to graph a circle. x² + y² = 9 has two y values for each x, so it is not a function of x. Use the parametric curve grapher or the polar graph generator instead.

Questions people ask

Any rule in x built from +, −, ×, ÷, powers, roots and brackets, plus sin, cos, tan, their inverses and hyperbolic versions, exp, ln, log, abs, floor and ceil, and the constants π and e. Write 3x or 2sin(x) without a times sign. Typing sqrt, pi or ^ in the math field turns into √, π and a power, so the expression looks the way it does on paper.

Sources

  • James Stewart, Lothar Redlin and Saleem Watson, Precalculus: Mathematics for Calculus, 7th ed., sections 2.2 (graphs of functions), 2.3 (local maxima and minima) and 5.3 (trigonometric graphs)
  • Richard L. Burden and J. Douglas Faires, Numerical Analysis, 9th ed., section 2.1 (the bisection method)
  • William H. Press et al., Numerical Recipes, 3rd ed., section 10.2 (golden section search)