Skip to main content
Search IntMath
Close

Sampling to create mathematical function graphs

By Murray Bourne, 23 Sep 2015

Sampling Functions

Graph sketching is a vital mathematical skill, whether we have access to computers or not. When modelling a data set, it's very useful to have a variety of curve shapes to choose from.

Curve sketching questions usually say something like:

"Sketch the given function, indicating main features of the graph."

When first learning to draw such function curves, students are taught to complete a table of values, something like this:

x −3 −2 −1 0 1 2 3
y −2 −4 −5 0 2 4 6

As long as the graph is a "nice", well-behaved curve in the region −3 < x < 3, then drawing a table is not a bad starting point.

However, a lot of students continue to do this for more complicated functions, and end up in a lot of trouble. It's important to have a general idea what the curve will look like before you start, so you don't miss key attributes of the curve.

Whenever you see a graph of a function drawn on a computer, it involves sampling. Sampling is constrained in that you want to produce a smooth curve, but not have a large file size (or require a lot of computer processing time). When humans sketch a mathematical function curve, some of the same considerations need to be kept in mind.

Let's look at some examples.

A symmetric curve

In this example (I'll tell you a bit later what the function is), we've sampled 4 x-values, completed the table, put the dots on the graph and joined them with straight lines.

x −3 −1 1 3
y 0.1 0.5 0.5 0.1

1234-1-2-3-41xy

We could have been a bit smarter and joined them with a curve, something like this. What do you think the function for this curve is?

1234-1-2-3-40.51xy

I've seen this kind of sketch many times. It looks reasonable, but it's wrong. The student has not sampled enough points and the curve does not capture all the required characteristics.

The student remembers that we should sample some more points to get a more accurate curve. So we try 7 points this time. The spacing between each point is 1.5 units.

123-1-2-30.51xy

Now our curve is taking on quite a different shape. We don't know if y = 1 is the highest point, but we have a better curve than our first attempt.

The next example uses 50 sample points, and we can finally get a good idea of the final shape from this.

1234-1-2-3-40.51xy

The curve we've been trying to draw is actually

{y}=\frac{1}{{x}^{2}+{1}}.

The maximum point is indeed (0, 1) and by considering what happens when x approaches negative infinity (on the left) and positive infinity (on the right), the denominator of the fraction becomes very large, so the fraction value becomes very small, and approaches 0.

Our first attempt indicated the curve passed through the x-axis, but we can see now that this is incorrect.

With enough sample points, we have captured all the required details on the graph. We can see the maximum point, and we can see the x-axis is an asymptote for the graph.

Very few students will draw up a table with 50 values! It's much better to examine the function first, and to consider what happens at some key points (like x = 0), and also what happens when x is very small, and very large. Another hint for drawing this function is that it's going to be symmetric about the y-axis, because of the {x}^{2} term in the denominator.

A polynomial

It's a good idea to know the general shapes of quadratic, cubic, quartic and quintic curves. If you know in advance the likely shape of your polynomial curve, it's easier to draw with less data points, and you're more likely to include all the key features.

Let's look at an example where things can go wrong.

We are given a polynomial function and asked to draw it. We find some typical values, using 10 sample points.

1234-1-2-3-4100xy

It seems to be a fairly well-behaved curve. We confidently join the data points with a smooth curve, then move on to the next question.

1234-1-2-3-450100150-50xy

But wait! Here's the original question:

"Sketch y = x4 + 8x3 − 13x2 − 92x + 96".

This is a quartic (highest power is 4), and this should alert us that there will be 2 arms of the curve that go off to positive infinity. However, our curve has only one arm going off to positive infinity, and the other going to negative infinity (or so it seems). There must be something wrong.

Let's try again with a wider view (we increase the range of x-values on the x-axis).

1234-1-2-3-4-5-6-7-8-9-10100200-100-200xy

That's better! Our curve shows the 2 arms that go off to positive infinity (it's positive because the number in front of the x4 term is positive). There's no need to zoom out any further since we can now see the main features of the graph. (The x- and y-intercepts, the local maxima and minima, and the behavior as the x becomes very small and very large.)

More complicated curve

Here's one that catches a lot of students. If you take the "plug values into a table" approach, you can get a really messy graph.

Our first try uses values that are about 0.5 units apart.

1.573.14-1.57-3.14510-5-10xy

Once again, we draw a smooth curve through our points:

123-1-2-3510-5-10xy

But it's not the correct graph. It has some of the right features (it suggests some repetition is going on and that it passes through (0, 0)), but it doesn't capture the key attributes.

Let's try again, this time sampling 70 points. Surely that should be enough?

1.573.14-1.57-3.14510-5-10xy

This time it's still not good. We have a large gap between the first and second arms (what does that gap mean?), and a jagged join between the second and third arms.

Let's have another go with 250 points.

1.573.14-1.57-3.14510-5-10xy

We can now see what the curve is meant to look like. It's actually the curve of the tangent function,

y = tan(x).

The problem with most graphing software is you often need to fiddle around like this to get a complete curve, and avoid unwanted joins.

In my svgPHPGrapher, I've built in the option to easily plot a curve where the slope is quite high, even when approaching a vertical line.

Plotting the Inverse for a better curve

My approach in the next plot was to graph the inverse function

x = arctan(y)

This curve is mostly flat when looked at from the side (that is, turning the axes 90°, which is what an inverse function is all about).

This gives just one arm, as follows. It only needs around 35 sample points to produce a smooth curve.

3.146.28-3.14510-5-10xy

Next, I repeat that arm across the board. I also inserted vertical asymtotes (the dashed lines) to indicate the curve gets closer and closer to those lines, but never touches them.

3.146.28-3.14510-5-10xy

Conclusion

While the approach of "plug values into the function, create a table, plot the points and then join them" is a reasonable place to start when teaching curve plotting, I feel it's important students should learn basic shapes of graphs. They are then less likely to have problems when sketching the curves by hand, and also when trying to use computer graphics software to draw curves.

See the 3 Comments below.

Leave a comment




Comment Preview

HTML: You can use simple tags like <b>, <a href="...">, etc.

To enter math, you can can either:

  1. Use simple calculator-like input in the following format (surround your math in backticks, or qq on tablet or phone):
    `a^2 = sqrt(b^2 + c^2)`
    (See more on ASCIIMath syntax); or
  2. Use simple LaTeX in the following format. Surround your math with \( and \).
    \( \int g dx = \sqrt{\frac{a}{b}} \)
    (This is standard simple LaTeX.)

NOTE: You can mix both types of math entry in your comment.

top

Tips, tricks, lessons, and tutoring to help reduce test anxiety and move to the top of the class.