For NotSchool
Maths Programming


  1. What are functions
  2. Polynomials
    1. Lines

What are they?

A mathematical function is a precise recipe for computing a number from one or more other numbers.

Example 1:  "to double a number" means to multiply it by 2.  We note these aspects:

  1. we use a name, "double"
  2. we use "a number" to mean the value that the function uses
  3. we give the recipe: "multiply it by 2"

We could make a table for this recipe:

value result
1 2
2 4
3 6
4 8
5 10
6 12
7 14
8 16
9 18

But it's not much good:  where do we stop? what values do we include?  It is better to write down the recipe in some compact form.

Instead of using English words we will use symbols to get this idea into a mathematical form:

Double(x) = 2*x

We can read this out again:  "the function Double of a single value x is two times that value x".

We use the symbol * (asterisk) for multiplication so that we don't confuse it with the letter x.  The multiplication sign can also be left out:

Double(x) = 2x

And we read that:  "Double of x is two x".

Note these definitions:

A letter is used instead of "a number".  That letter is very often the letter "x".  We choose "x" because we don't know what it is, we refuse to fix the number (otherwise we would be in the mess of the table again).  The letter is called the argument or the variable, and one says that "Double is a function of the variable x"

Round parentheses "(" and ")" are used just after the function name to enclose the variable. This may seem superfluous now, but it is not.

We can compute a few results:

Double(2) = 4

Double(45) = 90

Double(1'000'000) = 2'000'000

Double(0.5) = 1

And so on.  The recipe is much simpler to look at than any table.

Example 2: S(x) = x*x

Compute a few results:  S(2) = 4; S(3) = 9; S(12) = 144.

Or, as a table:

x S(x)
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81

This function is the square of its variable.

Drawing a function

Tables of values are not very good, and the mathematical formula is also not very visual.  Can we make a picture?  Yes:  look at the table of the square function S. Each row has two values:  one for x and one for the result of S(x).  Now draw a horizontal line and mark x-values on it with a ruler like this:

Use 1cm for each unit of x.  This line is called the x-axis.

Then draw a vertical line and mark values on it too, use 1mm for each unit, like this:

This line is called the y-axis, or, in this case, the S(x) axis.

Now make a red dot for each row of the table.  For example, for the fifth row, where the table gives the values 5 and 25, take the first value, 5, and move that many units (5cm) along the x-axis, then move up 25 mm and place the dot there:

When you have done it for all rows of the table the pattern of dots looks like:

You can put in more dots, for example if x=3.5 then S(x) = 3.5*3.5 = 12.25 and that gives a dot somewhere between the third and fourth one.

As you put more dots in, you begin to see a curved form:

That red curve is the set of all points where the y-value is the square of the x-value.

Doing it easier

Drawing S(x) from a table onto a piece of paper is a very good exercise.  You learn how it works only by doing it yourself by hand.

But now what if we want to study these functions:

L1(x) = 0.5*x + 2

L2(x) = 1/(x+3)

L3(x) = 0.1*x*x*x

That's a lot of drawing to do.  Please try it, and remember that mathematicians before 1950 did not have electronic calculators, they also had to compute the values by pencil and paper!

Today we have computers to do the tedious work for us:  on your Mac, find Grapher.

Grapher is hidden in the Applications folder, inside the Utilities folder:

Launch it; you will get:

Click the Open button. You will get:

(or perhaps a rather bigger version of this window)

The insertion point is blinking after the text "y=".  Type x*x:

Note how the "*" has been changed to a little dot, which is the normal mathematical symbol for multiplication.

Press return.  You will see the curve we made earlier with the dots:

It is black instead of red, and it also has the values when x is less than zero, but it is the same curve.  The units along both the x and the y axis are the same, that's why the curve seems to rise more rapidly up when we look to the right.  To reproduce what we did with paper, choose from Grapher's menus: View —> Frame Limits… and fill in the fields:

Don't worry about the funny numbers in the units boxes.  Then resize the window until you get something like:

Now let's add the L1, L2 and L3 functions too:

Use the little "+" button in the lower left corner of Grapher's window to create a new function, then type 0.5*x + 2.  Use the "+" button again and type 1/(x+3).  Use the "+" one last time and type 0.1*x*x*x.

You get:

except that all your curves will be black.  To colour them, first select the function in the left hand column, then click the inspector button at the top right and pick a colour.

Note:  as you have noticed, Grapher always uses the name "y" for each function.  That's not really a problem here.

Note:  you cannot see the third function (1/(x+3)) very well.  It is almost 0.  If you set the scales differently it will be visible:  choose View —> Frame Limits… and set the fields for x to -20 and +20. Now you can see more of the curves:


The horizontal axis of the graphs is called the x-axis or the abscissa axis.

The vertical axis or y-axis is called the ordinate axis.

The plural of the word axis is axes.

The axes cross at the point where x=0 and y=0, this point is called the origin.

A point in the graphs is defined by two numbers:  the x-value and the y-value, or: the abscissa and the ordinate.


Fine, we now know how to make an image of a function. We will go on to study lines first.

Valid XHTML 1.0 StrictValid CSS

next planned revision: 2009-01