Today is pi day so here is an interesting pi calculation: given the first n digits of pi (including 3!) what is the decimal position that that digit sequence first repeats?
Here is my python code:
pi = open('output.txt', 'r').read()
n = pi.__len__()
for i in range(1,9):
decplace = pi[0:i]
indx = pi[i:n].index(decplace) + i
print decplace + " @ " + str(indx)
And here is my result (read as 3 repeats @ decimal position 9 (3.141592653): 3 @ 9, 31 @ 137, 314 @ 2120, 3141 @ 3496, 31415 @ 88008, 314159 @ 176451, 3141592 @ 25198140, 31415926 @ 50366472, 314159265 > 100 million!
Since May 2012 I’ve kept a record of all the books I’ve read, including when I started and finished reading. Here’s my first attempt at visualising this data (using R and ggplot2).
Mathematics is poised to become one of the greatest tools for the further development of the biomedical sciences in the twenty-first century. Particularly due to the continual rise in available computational resources, mathematics is in a strong position to lend its precise, predictive power to the kind of problems that face modern biology. The whole discipline must grasp at this opportunity and become fluent in mathematics as applied to biological problems.
The current status of mathematics in the biomedical sciences stands in stark contrast to its continual role in the physical sciences where it has been one of the most invaluable tools in determining the nature of our universe. However leading scientists have long theorised that mathematics will someday take a similar role in biology too. In 1901 the statistician Karl Pearson wrote: “I believe the day must come when the biologist will — without being a mathematician — not hesitate to use mathematical analysis when he requires it.” But a push by any influential figures seems on the most part to have failed. Some limited progress has occurred, for example in ecology, but mathematics has yet to grasp the imagination of the biomedical sciences as a whole.
Further progress will require more of those who work with traditional methods to connect with the theoretical results arising from contemporary work in mathematical biology. At present this connection is far from evident — in fact citations have been shown to drop with the inclusion of a mathematical equation (Fawcett 2012). And unfortunately we can’t in general use the power of mathematics while hiding the equations! Mathematical literacy must increase among those who currently avoid it.
I would posit a single reason why mathematics has so long been fundamental in the physical sciences, and why it must now become so for the biomedical: quite simply mathematics can never be wrong. Mathematical facts are proven through manipulating a set of predetermined assumptions. If the assumptions are correct and the logic is correct then our result must also be correct. The only barrier to their validity can be human error, and the only barrier to their meaning, their metaphor.
What do I mean by metaphor? A bit like building a model aeroplane to put in a wind-tunnel, we can use mathematics to build small models that can predict real world consequences. To do this we must make simplifications — cut down on detail — but leave enough of whats important to answer our original question. Never need we attempt to design a ‘theory of everything’, all we need is a ‘theory of useful’. The inherent metaphor is simply how the inputs and outputs to our model represent the respective features in the real situation. This metaphor can take many forms depending on both the biology and the mathematical technique, for example the concentration of a molecule represented as a real number. Throughout, a successful model is simply one which simply suggests to us, or attempts to predict, something new about the world using whichever metaphor.
Experimentation will never stop being the ultimate technique for validating our theories as nature alone knows her true secrets and a model is only as good as its predictions. However we can easily learn to combine mathematical and experimental thinking to increase the rate of discovery. Models can be built relatively quickly (and cheaply!) to represent novel biological hypotheses, and permutation and repetition are easy to perform in silico. The predictions from these models can then be validated through experimentation, which can drive further modelling, ad infinitum.
The biomedical sciences themselves have recently entered the new paradigm of complex biological networks. No one has the right to assume that they can understand the behaviour of such a network with only their own brain power. Classically, understanding the behaviour of complex networks requires an abundance of careful observations, requiring an equivalent abundance of time and money. Mathematical models — more precisely, computer simulations of these models — are a better solution. Observation of the network under normal and abnormal conditions is then trivially easy, and can, for example, assist in the identification of upstream targets and downstream indicators.
So far, one of the most fundamental tools in the toolbox of mathematical biology have been differential equations, which excel at modelling the rate at which variables change. As mathematical biology becomes more mainstream, I expect that we will begin to see new links between biology and a greater variety of fields of mathematics. However where the fields will really begin to flourish in this partnership is when novel mathematics begins to arise with regularity from biological problems. In this sense I believe that biology can be to mathematics in the twenty-first century, what physics was to it throughout the nineteenth and twentieth centuries: a major driving factor behind new theorems.
The biomedical sciences need more than ever to embrace the power that mathematics can provide. Relevant mathematics simply cannot be ignored, and should not be distrusted any more than any other work published in the scientific literature. Once mathematical literacy improves, modelling should become a part of the standard biologists toolbox. This will give us countless opportunities to save time and money, and hopefully to drive discovery in both fields.
Fawcett, T.W., and Higginson, A.D. (2012). Heavy use of equations impedes communication among biologists. Proceedings of the National Academy of Sciences 109, 11735–11739.
Imagine you’re a biologist. Let’s say you specialise in ecology – how populations of animals interact with their environment.
You’ve decided to start a research project investigating a particular endangered species – let’s say a type of vole. This vole has one major predator – lets say a type of weasel.
Because the voles are endangered, it’s very important to have a good estimate of the number that are alive in the wild. But these voles live in dense rainforest and are very secretive. We have a rough idea of the size and location of their territory.
How might we find out how many there are?
We can’t possibly find every vole. We can do a small experiment – cover part of their territory with traps and count how many voles we see. We can then multiply up this number to represent the whole of their territory.
There are a number of issues with this approach. Among them are the assumptions that our knowledge of the area of their territory is correct, and that the voles are spread evenly over this territory.
In trying to work out the total number of voles, we’ve had to make assumptions – or simplifications. But we hope that we have a good enough method of working out something we can’t measure from something we can. This we call a “model”. A model of the real world if you like. And we’re use maths – so it’s a “mathematical model”.
We mean “model” in a similar sense to a model aeroplane. We’ve ignored some of the hard bits – made it smaller – focused on the important features. We can then go that extra step and use our model to find out something new about the real world.
Now skip forward twenty years. You’ve been counting the number of voles – and their predator, the weasels – every year. You think the data is accurate – and you’ve entered it into a spreadsheet.
One very simple mathematical model would be to assume that if the vole population is decreasing, it will continue to decrease at the same rate. That sounds fair. However when you look at the data – you find that you can’t easily predict what will happen next year! The numbers of voles isn’t decreasing each year – some years it even increases dramatically!
This is a problem. What do we do?
We need to take the number of weasels in the year – or perhaps the previous year – into account. And that’s when you need to build a more complicated mathematical model – one which includes all the things you know (and maybe some things you have to find out or even guess!). In this way we can make a model that makes a prediction of a future event.
“Hello, may I entertain you with some science?” This was how I introduced myself to countless strangers in St Pancras station over the past two weeks. I might not be an athlete, but I certainly feel like I’ve been put through my paces over the Olympics!
I was there as part of a team organised by the Francis Crick Institute in order to entertain, and maybe educate, the crowds on their way to the Olympic park.
It all started with me seeing a tweet from the Crick asking for volunteers to be trained as “science buskers”. The idea of approaching strangers and attempting to entertain them sounded terrifying! But it wasn’t something I could turn down as it’s one of my aims to seek out potentially embarrassing situations – to get the fear out of my system before it really counts!
There were two days of training from Dr Ken and Sara Santos of Maths Busking, who taught us 10 science “tricks” of which we could manipulate our favourites into a routine. Then we were let loose for a trial in St Pancras station – the verdict? Not quite as terrifying as anticipated!
I was caught on camera at the Somer’s Town START festival:
I did 10 hours of busking over the Olympic period (five two-hour shifts). We had been expecting to busk at people queueing for the Javelin train, but these queues never appeared during our shifts. The backup plan was to approach individual groups inside the station – far more daunting! Lesson 1: don’t look or sound like you are selling something.
There is definitely a skill in finding people to talk to. First of all they had to be stationary, ideally looking bored. I found families with children aged around three to ten was normally the best bet for the tricks we had to show. This meant that a lot of our time was spent looking for suitable people to approach.
Once we found a candidate family I found it was surprisingly easy to approach them without feeling nervous. I think that was a mixture of being in the right zone, and being somewhat able to hide behind the (rather fetching) Crick t-shirts. I found about 90% of people were happy to be approached, in some cases this required a run through of one of the tricks before they completely warmed to us. The rejections did tend to be upsetting, but I figure that’s one of the downsides to the job. In the least they helped me refine my technique of how to approach people. So, lesson 2: don’t be disheartened.
I tended to lead with the trick that was holding a ping-pong ball into the air by blowing air through a straw (demonstrated by me in the photo above). We would ask children and parents if they would like a go, often with positive responses. Of course, some were better than others! Unfortunately we couldn’t give out the balls, I was surprised how few disappeared!
My favourite trick was called Newton’s Revenge (which you can buy in magic shops). Here’s a video of the effect. This trick would get some wide eyed responses. Often people would work out that it’s due to a magnet – though the real explanation is slightly more complex than simple magnetism.
The question “May I tie your children up?” was generally answered with enthusiasm. This was my opener to a trick described at Maths Busking. Then we would finish by handing out a Crick Science Snappers.
On my fourth shift UCL interviewed me, Martin and Linda:
I volunteered for science busking expecting that it would be something to improve myself, but I heave learnt that interacting with children and encouraging them to enjoy science is rewarding in its own right, and that the act of science busking with the right audience is addictive! I’m looking forward to more opportunities to science busk, and to develop more science tricks (particularly biology related). Lesson 3: it’s a ridiculous amount of fun!
I’ll finish with two of my favourite responses:
I met a bunch of teenagers who knew how all of the tricks I showed them worked, and who finished with “Francis Crick went to our school”.
After describing that Francis Crick was “one of the men who discovered what DNA looks like”, and showing them a picture of DNA, the children that I was talking to began twisting around. I then pointed out that DNA was double-stranded and they should really be twisting in pairs, at which point they started hugging and twisting together.
“Welcome, my name is Dr. Curtis Connors”. He glances at his missing right arm. “And yes, in case you’re wondering, I’m a southpaw.”
We’re in a fancy research lab, somewhere in Oscorp tower – all glass and bright lights. Gwen has just brought in a group of new interns to meet her boss.
“I’m not a cripple, I’m a scientist and I’m the world’s foremost authority on herpetology. That’s reptiles, for those of you who don’t know. But like the Parkinson’s patient who watches on in horror as her body slowly betrays her, or the man with macular degeneration whose eyes grow dimmer each day, I long to fix myself. I want to create a world without weakness. Anyone care to venture a guess just how?”
An eager intern raises his hand.
Dr. Curt Connors: “Yes?”
Oscorp Intern: “Stem cells?”
Dr. Curt Connors: “Promising, but the solution I’m thinking of is more….radical.”
Unsure, the group looks at each other.
Dr. Curt Connors: “No one?”
“Cross-species genetics.” Peter emerges from the back of the group.
Peter Parker: “A person gets Parkinson’s when the brain cells that produce dopamine start to disappear. But the zebrafish has the ability to regenerate cells on command. If you can somehow give this ability to the woman you’re talking about, that’s that. She’s…she’s curing herself.”
Summer blockbusters have become an annual tradition of often fast-paced, action packed movies with popular heroes, villains and stellar visual effects to boot. Enlist a well-known cast and a good plot, and you’ve got a great recipe for success at the box office. But there’s another ingredient that filmmakers are trying to get right: science.
In an increasingly information-driven world, audiences demand realism. As University of Minnesota’s Physics Professor Jim Kakalios puts it, “a believable, fake reality”. Production houses now hire scientific consultants to help them create just that. Kakalios* lent his expertise to this summer’s The Amazing Spiderman, starring Andrew Garfield, Emma Stone and Rhys Ifans.
As Kakalios explains in the video, he created a complex-looking piece of math called the Decay Rate Algorithm. Supposedly, Dr. Connors has been racking his brain over this one key component, preventing him from successfully transplanting a lizard gene responsible for regeneration into another creature, thus ‘saving’ the world and himself. Enter his former colleague’s son, Peter Parker, who finds the perfect combination of letters and symbols scribbled among his father’s papers.
Notably, it’s not an algorithm, but two equations nonetheless. Kakalios was inspired by the Gompertz equation named after Benjamin Gompertz, a self-educated British mathematician. In 1825, Gompertz proposed that the rate of morality increases exponentially with age (now wouldn’t that make a great birthday card?). Kakalios also incorporated an expression from the Reliability Theory of Aging and Longevity (Gavrilov and Gavrilova, 2001), which predicts the failure rate of a multi-component system. But the resulting expression was too simple for the cliché Mad Mathematics, and even more so for one that could possibly produce a giant havoc-wreacking lizard bent on world domination. So… an extra logarithmic term was added.
Scientists external to the production process believe there is a tension in filmmaking between accuracy and entertainment. For filmmakers there is no tension. There is only entertainment. Accuracy is only important if filmmakers believe it generates entertainment value.
— David A. Kirby in Lab Coats in Hollywood: Science, Scientists and Cinema
We’re back at the lab. Everyone seems to have left for the day, apart from Connors and Peter. They’re looking at a 3D projection of images and information. A bluish lizard rotates in front of them.
Dr. Curt Connors: “What you see here is a computer model of lizard. Many of these wonderful creatures are so brilliantly adaptive that they can regenerate entire limbs at will. You can imagine my envy.”
Connors brings up an image of a mouse next to it.
“We’re trying to harness this capability in transferring into our host subject, Freddie, the three legged mouse…. Enter the algorithm now.”
Just as Peter is about to enter his father’s algorithm into the computer, he’s interrupted by a call from his uncle.
Dr. Curt Connors: ”Do you need to take that?”
Peter shakes his head and rejects the call.
Computerised Female Voice: “System ready for gene insertion”
Peter Parker: ”Okay. Check.” Peter drags the ‘gene’ across to Connors, who flicks it into the ‘mouse DNA’. ”What are we trying to do?”
Dr. Curt Connors: ”Pre-empt the protein.”
Peter Parker: ”Pre-empt the immune response.”
Computerised Female Voice: “Begin Trial.”
The mouse appears to struggle, attempting to grow a leg.
Connors shakes his head, dejected, turns away while the system attempts again and again.
Computerised Female Voice: “Algorithm accepted. Regrowth complete” Connors whips around in surprise. “Blood pressure normal. Regeneration successful”.
Dr. Curt Connors: ”Extraordinary”. Turns to Peter, and puts his one hand on Peter’s shoulder.
Dr. Curt Connors: ”Thank you”.
Yes, most of that is entertainment but it’s also real science. Computational modelling is widely used in science to either a) predict results that cannot be found experimentally or b) trial methods before costly clinical experimentation. It’s what I do for my PhD. But my plain desk, monitor and keyboard wouldn’t make a great scene to watch. Rather, swirling pink and blue DNA strands with graphs and numbers dancing across the screen are much more likely to garner interest.
Some other treats from the movie; the Lizard seems to retain his trail of thought and scientific knowledge from his human self and vice versa (in one scene, he selects and mixes two chemicals in the school lab, and throws the stuff at Peter). Connors also keeps a vlog, which documents his increasing craziness – if he put it on Youtube he’d probably have some followers. In another scene, he explains to Peter that the Ganali device (of doom) was considered controversial at its conception (more than 15 years ago), “so here it lies, gathering dust”. ‘Here’ is smack in the middle of what would be prime lab space, and the only ‘dust’ in that lab is probably on the soles of Peter’s shoes.
It’s also worth noting that the movie showcased some drawbacks of computational modelling. It’s not a cure-all – while the regeneration was modelled, the turning-into-a-lizard-with-destructive-tendencies was not. Disappointingly, there was also no explanation for the production of the Spiderman suit – a good plug for Material Science. It would have saved Peter some agony if he had thought about getting something bulletproof. An idea for the sequel perhaps?
And finally, the Movie Science Checklist:
Who runs the world? Norman Oscorp, apparently dying and needs to the ability regenerate. Fast.
Workspace?Oscorp Tower is a gleaming skyscraper that towers above the city, in a show of scientific power. You’d hardly ever find academic scientists in such spaces, but perhaps industry might be different? Anyway, it has to something worth climbing, for both Spiderman and the Lizard. Also proves to be convenient for the villain’s plans. Labs are shiny – glass, white surfaces, grey floors. Lab featured here is above ground**. Lovely views of the city. Branding on everything. Secure doors. On the other hand, the Lizard’s hideout/lab is in an underground tunnel**. Desk, laptop, multiple screens, papers strewn across – more like ones I see at work!
Lead scientist? Dr. Curt Connors. Male. Caucasian. Black rimmed glasses. No white hair.
Does the lead scientist have personal interest in the research? Yes. He wants a right arm.
Female scientists? Quick-thinking Gwen is Head Intern, no glasses. Some other female students in the group of new interns. Female scientists working in the background and running in corridors, wearing dresses. And heels.
Colours of the chemicals/antidotes/stuff they like to inject? Green for the regeneration-inducing injection. Blue for the antidote.
Computerised voices on high-tech systems? Check. Female? Check.
Scientist’s lack of work/life balance? Check. Lead scientist doesn’t seem to have a personal life. Peter increasingly lacking balance as well – although there is a sweet scene at the end.
Does scientist sacrifice her/himself in the name of research? Yes.
Sciences featured: Biology, Physics, Chemistry, Mathematics and Engineering.
The depiction and accuracy of science in the movies has come a long way in recent years. Yet, it’s a hard ask. We escape to the movies, in search of an emotional, creative and perhaps magical experience. Sometimes, we want to be escorted into a fantasy, to be given a chance to exercise our imagination and wonder at a world that isn’t ours. In the darkness of the cinema theatre, reality may be forgotten. But our curious minds still need convincing.
**The ‘cool’ science is sometimes depicted as being underground, carried out/stored in the basement (think Batman Begins). This may be partly true – UCL’s laser labs, MRI scanners, zebrafish facility etc. are in basements where there’s less interference from outside sources (such as rays from the sun).
Earlier today I had to give a three minute presentation on something that interested or exicted me, so naturally I chose “the logistic map“. My presentation follows (with a few additions):
I want to describe to you a little bit of biology-inspired mathematics, that will show how a simple system can lead to complicated results. What I am going to describe could apply to a number of different animals, but to be specific I’m going to talk about the miner bee.
Unlike most of the famous bee species these bees don’t live in colonies, and so they are known as solitary bees. Female miner bees lay their eggs in burrows. The next year the young bees emerge, fly around, mate, and by laying their own eggs the cycle repeats. In this way the generations are non-overlapping – parents and children are never around in the same year.
Now for some maths. Say we count the number of miner bees in Britain in 2012 – but this is costly, and we can’t afford to do it again in 2013. How do we estimate how many bees there will be? Well it seems logical that the number of bees next year will have some relation to how many bees there were this year. We can start with the simple relation that the 2013 estimate is equal to the 2012 count times by some number:
Ok, that’s fine, but why stop there? We can use the same relation to calculate the 2014 estimate given the 2013 estimate, and so on – 2015, 2016 and beyond. Now the value of is very important! We can easily work it out so we get no (theoretical) miner bees by (say) 2050, or conversely be swarmed in them.
An alternative could be to use what is known as the logistic map:
So now we have our previous relation, but it is also multiplied by this other term, which is related to the fact that only so many miner bees can live happily with the food and space available.
So what happens if we look into the future? Well again this depends on . Again if it is too small we get an extinction. But for larger values there is now some optimum bee population, which will persist for each subsequent year for all time. And no matter the starting number of bees (in 2012), we will always tend towards this optimum population.
As we increase further we get curious behaviour. A bifurcation occurs, which is when the systems suddenly displays some qualitative change. Here the optimum population is replaced by a optimum population that oscillates every 2 years! So the even years will have one optimum, and the odd years another. Increasing further, we get oscillations every 4 years, then 8, 16, and so on. Eventually we find oscillations every 3 years, then there is a mathematical proof which states that there are values of that will give oscillations of any number of years: e.g. 20, 59, 1254.
Then there are also values of that give chaotic results. Here I use chaos in a very specific sense, the number of bees predicted for each year will look random – but it’s not, because we know the rule that generates these predictions! Also any small error in reported in the bee census in 2012 will magnify up to large differences in subsequent years.
Chaos is something I find really interesting. There are suggestions that our brains are chaotic, and seizures happen when they lose that chaos. It’s also where the term “the butterfly effect” originated, but it’s another sort of insect and so I’ll stop here.
Here is my answer (from The Merry Wives of Windsor, Act IV, Scene 4):
jack-an-apes also, to burn the knight with my taber. FORD. That will be excellent. I’ll go buy them vizards. MRS. PAGE. My Nan shall be the Queen
The next shortest passages are:
extremest verge of the swift brook, Augmenting it with tears. DUKE SENIOR. But what said Jaques? Did he not moralize this spectacle? FIRST LORD. O, yes,
melancholy Jaques, Stood on th’ extremest verge of the swift brook, Augmenting it with tears. DUKE SENIOR. But what said Jaques? Did he not moralize this spectacle?
AJAX. Thou, trumpet, there’s my purse. Now crack thy lungs and split thy brazen pipe; Blow, villain, till thy sphered bias cheek Out-swell the colic of puff Aquilon’d.
Here is the python code I used to find this. It works by first finding consecutive lines that contain all letters, and then iterating through each match to find the shortest number of words that still match.
import re
max_lines = 5 #limit the number of lines we consider at one time
alphabet = "abcdefghijklmnopqrstuvwxyz"
space_regex = re.compile("\s{2,}")
curr_lines = []
results = []
for line in open("shakespeare.txt", "r"):
#keep running list of lines
curr_lines.append(space_regex.sub("", line))
if len(curr_lines) > max_lines:
curr_lines.pop(0)
#check for match in last (max_lines) lines
these_lines = " ".join(curr_lines)
if set(alphabet).issubset(these_lines.lower()):
words = these_lines.split()
fewest_words = these_lines
for j in range(len(words)):
for i in range(len(words)-j):
these_words = " ".join(words[i:(i+j+1)])
if set(alphabet).issubset(these_words.lower()) \
and len(these_words) < len(fewest_words):
fewest_words = these_words
results.append(fewest_words)
print min(results, key = len)
Every attempt to employ mathematical methods in the study of chemical questions must be considered profoundly irrational and contrary to the spirit of chemistry…. if mathematical analysis should ever hold a prominent place in chemistry — an aberration which is happily almost impossible — it would occasion a rapid and widespread degeneration of that science. [Wikipedia]
It reminds me of A Mathematician’s Apology by G. H. Hardy, which seems to have retrospectively rather outdated views on the applicability of certain fields of mathematics.
In the 40s the allies routinely bombed rail bridges to disrupt supply lines into Nazi-occupied France. After a raid, though, the Royal Air Force couldn’t fly reconnaissance missions over the targets as they were considered too risky, so it didn’t know if a bridge had been destroyed. The Special Operations Executive (SOE), however, came up with a novel strategy for finding out. By monitoring the daily prices of oranges on sale at various fruit stalls Paris, SOE agents dropped behind enemy lines were able to tell which supply chains had been affected.