Numbers index

Using Graphs webpage


Handling data --- Data --- Pictograms --- Graphs --- Sorting --- Box-and-whisker

Make a graph from a formula

The graph webpage was written for Secondary School children, aged 11+, although other ages may find it useful. It is an interactive webpage. This means that you can make it do things on the screen. Click here to find out more about this.

Pictograms are simple graphs, using small numbers. When you start having large amounts of data to display, then you need proper graphs. They can made in much the same way, gathering data, then representing each piece of data in the graph. Since there is so much data, you use a dot, or a line, or possibly a slice, to represent the data. This sort of graph can be made using spreadsheet software, such as Excel.

However, there is another way to make a graph. Rather than gathering data, you have a formula, such as y = x2. To make the graph, you take a range of numbers for x, such as 0, 1, 2, 3, 4, 5, and you use the formula to work out the value of y, which would be 0, 1, 4, 9, 16, 25. You draw a line along the bottom of the page, and mark out regular dots for the values of x. This is the x axis. Then you draw a line up the lefthand side of the page, and mark out dots for the values of y, the y axis. Now, for each pair of numbers, e.g. (3,9), you move across the page until you reach x=3 and up the page until you reach y=9. Then mark a dot. Do that for all values of (x,y). Now, join then up and you have part of the graph for y = x2. You can use other equations, of course, and you can have ranges of x which are partly negative. Then the x and y axes will be in the centre of the page, like a cross, rather than along the edges.

Equations tend to have the same shaped graphs. y = x2 is a quadratic, which makes a parabola, a graceful sweep downwards towards to zero and back up (if you have a range which includes negative and positive x). It can be helpful to know these shapes, and to experiment changing the variables in equations to see what effect it has on the graphs. But drawing graphs by hand is tedious (although I think every child should do some rather than trusting the computer all the time!) So this webpage allows you to choose a equation, and then play around with variables, range and scale to see what happens.

First choose a type of equation. A linear graph is x, quadratic is x2, a cubic is x3 and a quartic is x4. A reciprocal is 1/x, and you can have 1/x2. The 'general algebraic' is a mixture of all of these. (It is not a completely general algebraic, but there are limits! This webpage explores simple equation only). Then there are sine, cosine and tangent graphs. When you choose a type of equation, or change a variable, nothing happens until you click on the Draw graph button.

You can change various variables. The equation allows various terms, for example the quadratic allows x2, x, and a constant. To start with, the x and constant are set to zero, so you have the simplest form of quadratic. I suggest that you draw that first. Then try to change just one variable at a time, for example, change the constant (on the end) from zero to a number, and see what happens. If you change more than one variable at a time, then you can't disentangle what effect it has.

You can alter the range of x to various values. These all include negative as well as positive values, as these graphs look more interesting. You can also choose for the webpage to calculate the y range for you, or to make the y range the same as the x range. Try playing with the ranges for a particular equation to see what effect it has. Sometimes the graph looks different for different ranges, and sometimes the same. Work out why. Getting the webpage to calculate the y range means that the y axis won't necessarily be the same scale as the x axis.

The webpage marks the minimum and maximum values on the graph, so check this to see what the scales are. The x axis is marked off in dots, but not the y axis (a technical reason for this!) The x dots are every one or every .1 depending on the range. Remember, click on Draw graph to get the new range. It's certainly worth changing the ranges to see if it makes a difference. Sometimes when you change the variables, the interesting part of the graph happens outside the current x range, or the interesting part is in such a small part of the graph that you can't see the details. A simple reciprocal with x range -1 to 1 and the y range the same as the x range just shows 2 dots! Alter the ranges to see the graph properly.

You can alter the width and height of the graph. This does not alter the shape of the graph (although it might alter the proportions), it just gives more precision. If you select a big width, the graph will take longer to display.

You can choose a joined up graph or dots. The dots are the calculated values.

Mathematical equation should be written in a specific way. For example, if a term is multiplied by zero, it doesn't appear. However, when changing the variables, you need the term whether it is multiplied by zero or not (in case you want to change it). So the equation is displayed again, correctly, above the graph, once you have clicked on Draw graph. This also sorts out the inelegancy of adding negative terms, or single terms.

The Trig graphs (sine and cosine) use radians as x values. 180 degrees = pi radians, which means that a radian is about 57 degrees. I suggest you try an x range of -5 to +5 or -10 to +10 for the sine and cosine graphs, although changing the variables may need a different range. While the simple tangent graph will be OK, you may run into problems once you change the variables. Tangents have an unfortunate tendency to have discontinuities (disappearing off to infinity, and reappearing from minus infinity). This is no problem if drawn manually, but can confuse computers!

How to use this webpage

A teacher might like to use it as a simple demonstration tool in the classroom (or parent doing home schooling). You can use it to familialise the children with the shapes of various graphs. You can also demonstrate that range matters, and what difference making the scales of the x and y axes different or the same. Keeping x and y ranges the same, you can explore gradient. You can also use it to solve equations graphically (see below). You can let a bright, mathematically inclined child loose on it, and see what they discover (it's always useful to have something for the child who has finished classroom exercises early). Finally, some graphs are just pretty shapes, so why not make a few and just admire them.

Solving equations graphically:When a graph crosses the y axis, it gives the y value when x is zero. This is usually easy to work out arithmetically, by making x=0 in the equation, and working out what y is. So the graph doesn't help here. But when a graph crosses the x axis, it gives the x value when y is zero. This is not necessarily so easy to work out, so you can use it to solve the equation. Linear equations are not much of a problem, but you can demonstrate that the graph does, indeed, solve the equation when y=0. For example, y=x-2 crosses the x axis at x=2, and x is indeed 2 when y=0 in the equation. Quadratics are more of a problem. There is a formula:

If 0 = ax2 + bx + c, then x = (-b SQR(b2 - 4ac)) / 2a

Rather a mouthful! However, set up the graph for a quadratic, and wherever it crosses the x is the solution. What's more, a quadratic may not have a solution in real numbers. This is when b2-4ac is negative, so there is no real square root possible. Here the quadratic never touches the x at all. Cubics and quartics are even harder to solve.

Some possible graphs to try:

Lineary = xTry changing x range.
Lineary = 2xMake y range same as x range and compare with y = x.
Lineary = .5xTry changing both ranges.
Lineary = x + 2Where does graph cross x axis? Why?
Lineary = x - 2Where does graph cross x axis? Why?
Quadraticy = x2Try changing both ranges.
Quadraticy = 2x2Make y range same as x range and compare with y = x2.
Quadraticy = x2 - 9Where does graph cross x axis? Why?
Quadraticy = x2 + 9Does graph cross x axis? Why (or why not)?
Quadraticy = x2 - 3x - 4Where does graph cross x axis? Why?
Quadraticy = x2 + 5x + 4Where does graph cross x axis? Why?
Quadraticy = x2 - 5x + 4Where does graph cross x axis? Why?
Cubicy = x3Try changing both ranges.
Cubicy = x3 + 2x2 - 11x - 12Where does graph cross x axis? Why?
Cubicy = x3 - 64Where does graph cross x axis? Why?
Quarticy = x4 - 2x3 - 13x2 + 14x + 24Where does graph cross x axis? Why?
Quarticy = x4 - 256Where does graph cross x axis? Why?
Siney = sin (x)Try changing x range. (Best to allow calculation of y range.)
Siney = 2sin (x)Why is it different from y = sin (x)? (Look at y range.)
Siney = sin (x) + 2Why is it different from y = sin (x)?
Siney = sin (x + 2)Why is it different?
Cosiney = cos (x)Why is it different from y = sin (x)?
Sine + Cosiney = sin (x) + cos (x)Why is this different?
Sine + Cosiney = sin (2x) + cos (3y)Try changing x range and width of graph.
Tangenty = tan (x)Try changing x range.

If you want any help answering these questions, email me (see Numbers index).

Make a graph from a equation