## Mathematica details of the cooking with mathematics post

Edit: If you want to see the full code, I include everything in this post in the Mathematica file here.

I promised previously that we would go into depth into the graph theory and food calculations, so today we will do just that. This will be Mathematica heavy, so really this is only aimed at those who have played around with the Mathematica programming language.

I’ve been using this language now for over a decade, and while it is not the fastest language on the market for doing numerics-heavy calculations, it is an incredibly versatile language, and for getting code written fast, it’s hard to beat!

I tend to code in what is called a functional programming style (ideal for Mathematica), which doesn’t use loops as you would normally find in a procedural language. Perhaps the most oft used coding syntax you will see below is of the form:

somefunction[#]&/@{el1,el2,el3,el4…}

which takes the elements of a list and passes them one by one into a function.…

## A Mathematics Problem from the SBITC

The Standard Bank IT Challenge (SBITC) is an annual coding competition for undergraduate and honours students in South Africa. The contest consists of two rounds: a regional event named the “heats”, and the final. In the heats, teams of up to four students each compete against other teams from the same university, and the winning team from each of the nine top-performing universities is invited to the final round in Johannesburg. Each member of the winning team wins a prize, and the winning university receives a large cash prize, but students mostly participate for the enjoyment that is to be obtained in solving the problems, and to test their skills against a set of problems that is designed to challenge the participants.

This year, the final problem from the heats (which took place on Saturday, 16 May) was fairly mathematical in nature; or more-so than the other problems at least. Essentially, the problem asks the following:

We consider generalised Fibonacci sequences $T_n$ which satisfy the same recurrence relation $T_{n + 2} = T_{n + 1} + T_n$ as the Fibonacci numbers, but with the first two terms $T_1$ and $T_2$ being arbitrary positive integers.…