Knit one, pearl one is the start of a knitters algorithm. My mother loved to knit.  She could invent complex patterns in her head and knit them out to any size or shape you required. They were truly works of art.  She knitted hundreds of Smurf dolls for us to hand out on a number of Variety bashes, each one totally unique.  Lia was a composer of knitting, as well as a master practitioner.  I was a happy observer, user and spruiker of her expertise.  Maths is knitting’s thought experiment cousin.  With knitting, maths, music, art we can all appreciate the end product but few of us are capable of composing new ideas.  We can all perform each to some degree. Vale Lia and many thanks.

Linear Equations

Algorithms that lead to a solution are called equations (or formula). Maths is mostly about equations – we are always after the answer. Equations are like the two sides of a scale. To be in balance the same (weight/value) must be present on each side. We can perform operations on each side ( eg add, subtract, divide etc) and if we do the same thing to each side the equation remains in balance.

They are often written in the form y = 5x +7 where x can be any number that we can find on the number line. 5x means that number times 5 ( eg if x =2 then 5x =10 and y = 10+7 =17).  So for every x we have a given solution y. Y can also be thought of as a function of x and in this notation we write y = f(x).

Another way to look at this equation is to create a graph. Here we have 2 dimensions which we can call x and y,  with x values along the horizontal axis (just another number line) and y along the vertical (or 2 dimensional space).  We can use an excel spreadsheet (or other mathematical app) to produce these or we can draw them on a piece of graph paper.  I have used Excel to show the above graph (from x = -15 to 15).  The result is a linear graph (ie a straight line) with a slope of 5:1 and a y intercept of 7. The red squares show the discrete numbers I entered and the straight line has been fitted to this trend, making a continuous set of solutions. Graphs are a great way to envisage solutions to algebraic equations.

We can easily see the slope of the graph (although in this example the x and y scales are not displayed equally – always look at scale bars!). We can also determine the solution of the equation for x and y (called the root). For x = 0, y =7 and for y = 0, x = -7/5 = -1.4. These solutions can be determined by substitution into the equation or looking at the graph.

We can write the equation in a more general way where y = ax+b.  Now the slope is a, solutions are y=b (intercept) and x= -b/a and this equation defines the set of linear equations (or all the straight lines in the universe using a Cartesian coordinate system).  Amazing yet again!

This is the basis for the Simplex algorithm that was discussed last time. Linear programming is a way of defining all of your problems as linear equations and optimising them using the Simplex algorithm to find the best solutions.  Graphically we could show the optimisation as the intersection of 2 linear graphs.  Here the vertex or optimised point is at x =2 and y =17 where these may be measuring time and money for example.

So an algebraic equation is a way to describe a mathematical problem, an algorithm is a set of steps to solve that problem (good for computers, as a set of steps is how computers work) and a graph (geometry) is a good way to visualise a solution. The actual Simplex algorithm in code gets quite complicated.

Mathematicians have found that quite a few systems can be defined by a set of linear or near linear equations, allowing these systems to be optimised by the Simplex algorithm. Routines can be used to optimise traffic lights, lithium ion battery charging, grid power supply and many other processes. Thanks to George Dantzig’s work in the 1940s and modern computers we can now optimise many thousands of parameters described as linear equations.

Quadratic equations are the simplest polynomials (equations with several power terms) where there is at least one x² term and no higher powers. The simplest of these is y = x² and describes a parabola in graphical form.  The solutions or roots are that y=0 when x = 0. The function is always positive in real space.

The generalised form of a quadratic is y= ax² + bx +c and the roots are given by the quadratic algorithm described previously.

For example lets look at the quadratic y = x²+3x-10 and its roots.  If we plot a graph we can see that the roots (where y =0) are where x = -5 and +2.  You can look at the graph where the horizontal line y = 0 cuts the x axis at -5 and +2.  Or even easier you can look up the answer in the list to the left of the graph.  In this instance I have chosen a quadratic with integer solutions, so they are entered when I calculate each integer point.

In this instance a=1, b=3, c=-10 so we can also calculate the roots using the quadratic algorithm (in this instance a fairly simple formula devised by Mr Algorithm himself Al Karizmi. The formula is So I guess he was right. This algorithmic method is the way you would derive a solution on a computer.

My favourite method of solving simple quadratics is the factorial method. This is more like doing a puzzle (like a Sudoku).

Now y = x² + 3x – 10 = (x-2)*(x+5) and therefore y=0 when x = 2 or -5.

(to check this we multiply out the terms in brackets =x*x- 2*x+5*x-10= x²-2x+5x-10 =x²+3x-10)

And there you have it – a multitude ways of finding the roots of a quadratic.

If you followed all of that you are well on your way to becoming a mathematician. If not, try playing with the numbers yourself either on graph paper or using a spreadsheet.  You might find it fun!! 