Friday, 29 July 2016

The past few weeks have been, for lack of a better word, drab, boring, incomprehensibly dull, insignificant, and unduly torturous, so much so that I can no longer muster the enthusiasm to partake in any activity that a functioning member of society would enjoy. 

That was a lie, it wasn't so bad, I just didn't know what to write. Well, it's been so long since my last post that I don't even know what to say about what's been going on. I went to China. Yes. I got bitten 43 times on one leg by mosquitoes. Yes. I am no longer capable of finding enjoyment in many activities. To a certain extent, yes. I wish I could just sleep and sleep and wake on the morning of August the Eighth...

Ok I should really stop myself from descending into depressing sounding words and sentences. (I only just realised that Eighth is spelled really funkily, like it ends in 'hth', how cool is that!!! - not very cool I imagine) The fact remains, I kind of want to get started with university life already, back to a place where I have a schedule, where my day is full, where there's always something to be done, even if I don't want to do it. A place where success is standardized. (<- I don't really know what that means, but it sounds deep)

So recently I've been messing around with a couple of problems, foremostly I've been thinking about (but not really doing much about) the 'density of rational points on circles', where a rational point is a point with rational coordinates, density is used in the normal sense of the word, and a circle is a circle. But what is a circle, but an idea, a form! A circle is pure, whereas the cruddy things we draw with compasses are just a representation of it, a shadow of the purity of a true circle... (I'm doing greek philosophy in my first semester haha)

Yeah. Not much to say, because life is much the same as ever. 

^Scott Pilgrim vs the World comic was pretty good, but I have no idea why
I only laughed like once during reading the whole thing, the plot made like 5% sense, I really don't know why I kept reading
The art was good at least
Well not 'good', but like 'to a professional standard good'
Like better than onepunchman webcomic good
not like escher good
yeah


Wednesday, 11 May 2016

Peace and Tranquility - my soul's descent into the void

Greetings, followers of Pete Patterson. It's been a long day, but I'm still here. I'm still eating, moving, pooping, whatever it is that classifies me as 'alive' and not 'dead'. Still walking, talking, still dreaming. Still wasting time. You might wonder: "Pete, you sound bloody soul-less man." Very observant. My soul is in the last stages of escaping the encasement of meat known as my body, and drifting off to a better, albeit darker place. And the culprit of this change,

I got a job.

It's just a part-time one, the details of it don't really matter. Fact is, I got accepted to UC Berkeley, so I'm in Sydney with a couple of months to waste. "Haha, I'll get some money from a job!" I said. "It won't be that bad!" I said. Just two weeks in, and I feel like floating down the river styx, whispering prayers of a dead man. Every minute, every second is an eternity.

In other slightly less depressing news, I think I solved a long-standing problem I've had. The problem is pretty easy to state. Suppose I have a magnetic field that looks like:

$$B(x,y,z,t) = t\hat{z}$$

what's the electric field like? I've had quite a long history with this actually. When I first thought of the problem, I thought I could figure it out using the integral form of Maxwell's equations. (this one: $\int E\cdot d\vec{l} = -\frac{d\phi}{dt}$, where the line integral of the electric field is given by the change in magnetic flux through that surface). It didn't really work out though, because I just ended up with a bunch of line integrals telling me that the electric field should swirl 'anticlockwise' everywhere (when looking down the $z$ axis), but not actually getting me the electric field.

I asked senpai M about it, and he said something wise along the lines "Maybe the integral formulation ain't good enough, try the differential formulation. And remember, boundary conditions!!" and I was all like "er ok that's cool" (I didn't know a thing about the differential formulation).

Anyways, many months passed, and since I was learning a bit of vector calculus (about time) (I hope that's what it's called, the one with all those upside down triangle things) I thought I'd try solving it again. So I popped out my Maxwell's equations from google:

$$\nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0}\\
\nabla \times \mathbf{E} = -\frac{\partial \mathbf{B}}{\partial t}\\
\nabla \cdot \mathbf{B} = 0\\
\nabla \times \mathbf{B} = \mu_0 \mathbf{J} + \mu_0 \epsilon_0 \frac{\partial \mathbf{E}}{\partial t}$$

With the given situation, we know $\mathbf{B}$ for all $t$, and let's just assume there ain't no charges in sight either. By subbing in these conditions we get the equations:

$$\nabla \cdot \mathbf{E} = 0\\
\nabla \times \mathbf{E} = -\hat{z}\\
\frac{\partial \mathbf{E}}{\partial t} = 0$$

Notice that the last equation tells us that the electric field is static (because there ain't no curl in the magnetic field). Finally, we can crack these nuts into all their components, and we get 4 equations that $\mathbf{E}$ has to satisfy:

$$\frac{\partial \mathbf{E}_x}{\partial x} + \frac{\partial \mathbf{E}_y}{\partial y} +\frac{\partial \mathbf{E}_z}{\partial z} = 0 \\
\frac{\partial \mathbf{E}_z}{\partial y} = \frac{\partial \mathbf{E}_y}{\partial z}\\
\frac{\partial \mathbf{E}_z}{\partial x} = \frac{\partial \mathbf{E}_x}{\partial z}\\
\frac{\partial \mathbf{E}_y}{\partial x} - \frac{\partial \mathbf{E}_x}{\partial y} = -1$$

The thing about this solution that for some reason I never anticipated is that there are like heaps and heaps of solutions. For some reason I thought given a $\mathbf{B}$ field, then the corresponding $\mathbf{E}$ field is unique, but it depends on the initial configuration of the $\mathbf{E}$ field. Whatever the initial $\mathbf{E}$ field is (as long as it sticks to the four rules above), that's what the $\mathbf{E}$ field will be forever.

Probably. I'm about 66% sure (I only just learnt upside down triangle, the chance I made a mistake is not negligible). Anyway, if this is right, then one potential answer is:

$$\mathbf{E} = -x\hat{y}$$

which seems alright to me.
OYEA P.S. I remembered what was bugging me. If the $\mathbf{E}$ field is like stationary, then so is the energy stored in it. But somehow the magnetic field just grows and grows with time. And like, isn't the energy stored in a magnetic field something like something times $B^2$? Then energy shoots up as time goes on, does energy conservation just go out the window?

-----------------------------------------------

I've forgotten why I started this blog now. I might as well use it as a place to remember stuff. I thought up a problem the other day (which is really in the same vein as a whole bunch of other problems that I've done) that seems hard but who knows.

Adventures of Melon boy, part 2:
Melon boy is back at it again! This time, he lives in an $n$-dimensional space. A set of coordinates $(x_1, x_2, x_3, ... x_n)$ define a point Melon boy can travel to, provided that $(\forall i)(0 \leq x_i \leq m)$ where $m$ is the 'size' of the grid. Each point is either a melon (with a 50% chance) or a pumpkin (with a 50% chance). If Melon boy is currently at a point $(x_1, x_2, x_3, ... x_n)$, he can travel to a point $(y_1, y_2, y_3, ... y_n)$ if the condition: $(\exists j)(0 \leq j \leq n)$ such that $[(|y_j - x_j| = 1) \wedge (\forall k) (k \neq j \Rightarrow y_k = x_k)]$ holds. Melon boy can travel from square $x$ to square $y$ for $0$ time if the squares are both melons or both pumpkins, else he travels for $1$ time. Melon boy starts at square $(\forall i) (x_i = 0)$. What is the shortest time it takes him to get to square $(\forall i) (x_i = m)$?

I'd rate the probability of that making sense (even to myself later on) as 33%. So, here, have a diagram:
A case for $n = 2$ and $m = 6$ (2 dimensional, 6 big square). The squares are either red (pumpkin) or blue (melon). The green numbers written on each square is the time it would take melon boy to get to that square if he took the most efficient path. In this case, melon boy can move up right down and left. In this case, the time to get to the upper corner is $t = 4$. 

That's all for now folks. Stay tuned. Hopefully my soul doesn't escape any further than it already has. 

Thursday, 10 March 2016

Updates on life

Who knew, that I would one day write a blog post just to give an "update on life"? It's almost like I think that someone will read this, apart from me. Actually, it's pretty impressive that I haven't completely given up posting things yet, its been at least a couple of months (I think). Anywhoo, life has been hella tiring. Seriously. Imagine running a marathon, whilst solving the Schrodinger equation for a N-particle system, whilst head juggling a soccer ball for ten hours straight. That's what life is like right now, and I DON'T EVEN KNOW WHY. I don't even have that much to do, but somehow I still feel so tired. Perhaps it's related to the fact that I am constantly surrounded by people for 80% of my waking hours, so I don't get any lonely time. Who knows.

Anyhow, here's two small things that I've done (ish) :

Ah, the classic block on a plane. Just as classic as foggy glasses whilst eating two minute noodles at 5 am, or getting wet because I was walking in the rain. Absolute classic. A friend of mine however (a man named Y) suggested a variation of the problem. In the variation, the triangular plane (the black object in the picture) exists on a frictionless table, i.e. as the red block slides down the plane, the plane will (probably) slide to the left. The question is, will the red block reach the bottom of the plane faster if the plane is on a frictionless table, or if the plane is fixed in place?

To solve this problem, I introduced two variables, $x$ and $y$, and just Euler-Lagranged it like WHAM WHAM WHAM.. DOWN FOR THE COUNT! The answer I got is:

$$T' = T \sqrt{\dfrac{M + m \text{sin}^2 \theta}{M+m}}$$

Where $T'$ is the time it would take the red plane to get to the bottom if the plane was on a frictionless surface, and $T$ is the time it would take if the plane is fixed. Checking the boundary case of $\theta = \pi / 2$, we see that $T' = T$ as required.

Anywhoo, there's only one other thing of any slight interest that I've done:

A man sits in a room. Every second, he says a random number between $1$ and $N$. How many seconds on average pass before he has said every number between $1$ and $N$ at least once?

This has real implications, in that originally I was trying to estimate the time it would take for a system to explore all of it's 'accessible' microstates. The rough way I sort of maybe solved it was to consider the expected number of 'duds' (i.e. number of numbers that the man says that he has already said at least once) as a function of the number of unique numbers that he has said so far, and sum that up. (by linearity of expectednesstation)(I think). Anywhoo, the answer I get involves some harmonics (sums of $\frac{1}{N}$), but crudely (for large $N$), it's probably:

$$T = N \text{ln}(N) + N$$

(I say probably, because I'm running a simulation right now to see if I'm right or just completely off whack. I'm probably right. Probably.)


The above plot, for $N$ up to $100,000$, shows the 'actual' rough value in blue, and the guessed value in green. As can be seen, it seems an OK guess

Just another note on life: My sleep pattern is completely off whack, it's getting close to 3:00 AM right now, which is pretty bad. But I'm running an experiment, recording all my sleep times, and whether or not I have a dream, and whether I remember it or not, to see if dreams have any relation to sleep times.
Anyway, Ima pop ma clockers, see you laterz

And this is for $N$ up to a million.




Saturday, 20 February 2016

Diffraction through glasses

I believe I have just made the greatest discovery of my life.

I was out walking on campus, chilling in the chilly air, thinking about computer learning, quantum mechanics, pretty girls and loneliness, when all of a sudden I looked up, and was startled out of my reverie. The image that caught my attention was:


Let me explain. That grey twisting noodle on the bottom is the path I was walking on. That orange ball of heavenly fire is a lamp on a lamppost. What was REALLY amazing were the two lasers that shot up and down from the lamp, extending to infinity. Of course, the lasers didn't ACTUALLY exist, I only saw them because of my glasses. For some reason, my glasses were causing the light from the lamp to stretch only up and down, and it actually looked quite pretty. 

I thought a little bit about WHY this would happen (because it is a little bit strange). And then it hit me. The revolution of all revolutions. 

I WIPE MY GLASSES WITH MY SHIRT LEFT TO RIGHT!

Conjecture: Because I wipe my glasses with my shirt in a left-right motion, it distributes the grease on the surface of the glasses into horizontal grooves. Then, when the light from the lamp comes towards my eye, it encounters these horizontal grooves, and gets diffracted (up and down). This causes the vertical lasers!

Evidence: I then proceeded to wipe the glasses in an up-down motion, and LO AND BEHOLD! When I looked at the light now, the light was now blurred out in the horizontal direction! This is simply amazing! What a wonderful world we live in!

(Of course, I could be wrong. But it just seems so plausible! Right? Riiiiiight?)



Thursday, 4 February 2016

A creative from grade 5

I stumbled upon this gem, and I couldn't help myself. It's simply beautiful.

----------------------------

As Jim walked onto the calm and quiet beach of an unknown land, he wondered if he was the first person to step onto Dead Island.

Every step Jim took, he became more afraid of what he would find. He heard a scrunching sound under his foot, so he lifted his foot to find the hidden, and cursed map of Dead Island.

As soon as he picked up the scrunched map, shuffling noises could be heard nearby. Jim froze like a statue, and tried to navigate where the noise was coming from, but it seemed as if the dreaded noise was coming from everywhere. Jim ran as fast as he could to escape the noise. But it was getting louder.

Suddenly pirates with black eyepatches and curved and sharp daggers jumped out of the sand and roared. It was an ambush. Jim was surrounded by pirates. Jim tried to escape, but the pirates were too fast. Then Jim came up with a brilliant plan that he hoped would work. He cupped his hands and threw sand at the pirates' eyes. The pirates roared in agony, and Jim ran past.

As Jim jumped into the forest, he heard a faint tapping noise coming from the trees. As he looked up, squirrels popped out of their homes, armed and loaded with acorns. The first squirrel threw an acorn at Jim, and it narrowly missed. Then all the thousands of squirrels in the forest were throwing acorns at Jim. Jim dodged, ducked, jumped and parried, but there were too many squirrels.

Suddenly, a bright light bulb flashed in Jim's fabulous mind. He took a bucket out of his bag and held it above him. The bucket was filling up with acorns.

A few minutes later, he escaped the forest and looked at the map. He followed the dotted route until he reached a dark cave. Inside the dark and gloomy cave, a golden treasure chest lay. As he opened the beautiful chest, he found a thousand pieces of pure gold.

As Jim returned home, he learnt something. Every cloud has a silver lining.

--------------------------------

It's beautiful, isn't it? Here's another one, that actually is pretty interesting:

--------------------------------

I have got a perpetual fear of dying infinite times. You might think I am crazy, but it is possible.

Just imagine. You are in the savanna. You see a wide panorama of grass. Suddenly you hear a rustling noise. You look around. A rhinoceros is charging at you. You scream just before you die...

You awaken from your dream. You are a military soldier who is fighting in World War 3. You race out with a rifle. Suddenly, 10 bullets hit you. You collapse onto the blood soaked ground...

You awaken from your dream. You are in school, and it is lunchtime. You decide to tease Jacky. "Rejected!" you say to him. Jacky's face turns red and he pounces on you. He puts his hand to your throat. He strangles you. Your eyes close, your lungs tighten. You are dying...

You awaken from your dream. You are relaxing in Hawaii in your little chair. You start to hear a humming noise. You can just discern a black shape in the distance. It is getting bigger. The noise is getting louder. Suddenly, something is released from it. It is flying towards you. You scream. The hydrogen bomb explodes. You die...

You awaken from your dream. You are sitting up in your bed. Beads of sweat are rolling down your face. You calm down and realise you are alive.

So, do you now know why I have a fear of dying infinite times? It could happen to you! Just wait until night time...

-----------------------------

So anyway, onto more actual bloggy stuff. I'm going to ANU soon, to do a "Bachelor of Philosophy" (sort of a science degree, but with 'research' in it too!!). That's all I have to say about that.

Wednesday, 13 January 2016

A tedious approach to finding the average span of a 1-Dimensional Random Walk

A good while back, I first encountered across the Prime Dragon. At the time, I wanted to find the average 'area' of the Prime Dragon, or the number of unique points it visits after $N$ moves. Of course, like many problems I think of, it's pretty much impossible for me to do (I'm not even sure if it can be done). In an effort to make some progress to this daunting question, I reduced the problem to a one-dimensional case, and asked "What is the average span of a 1-Dimensional Random Walk (50% chance stepping right by 1, 50% chance stepping left by 1)". At the time, I thought this would be a relatively easy problem, but over a while I couldn't find no easy way to do it. In the end, I produced this twisting, winding and tedious approach to finding the average span of a 1-Dimensional Random Walk (at least it works I guess lol). I'll go try and see if I can find online the actual way to do it, because I'm pretty sure there must be a really elegant solution out there somewhere. Anyway, the 'official problem statement' is (I don't actually know how to state it properly but I'll try my best):

Given a set of $N$ numbers, $Q = {q_1, q_2, .... q_i, .... q_N}$ such that every $q_i$ has a 50% chance of being $1$ and a 50% chance of being $-1$, find the expected value of the 'span' of the set, where the 'span' is defined as $$S =  max(\sum_{j=1}^{N}\sum_{k=1}^{j}q_k) -  min(\sum_{j=1}^{N}\sum_{k=1}^{j}q_k) + 1$$ 
To understand problems, a wordy definition is also useful, so here's a story statement:
Timmy the Dog lives on a one-dimensional line. Timmy's home kennel is situated at $x = 0$. Every day, Timmy (being an adventurous pup), either increases his $x$ coordinate by $1$ (with a 50% chance), or decreases his $x$ coordinate by $1$. Each time Timmy visits a new place, he pees on it, marking his territory. After $N$ days, how many places on average will Timmy have visited (including his home kennel)?
 An example of $N = 5$, where Timmy the dog starts at $0$, goes to $1$, then $0, -1, -2$ and finally $-1$. The amount of places Timmy has visited in this example is $4$ (${-2,-1,0,1}$).

When I first attempted this problem, I did some pretty silly things, like finding where Timmy ended on average (which didn't really help, because we want to know where Timmy has been). Eventually I sort of willy-wonkered myself back onto track, and now I finally have a solution. Solution is made up of several parts.

Step 1: The Foundation and Realization
The average $S$ (where $S$ is defined to be the span), is defined by the following formula:
$$\bar{S} = \sum_{j = 0}^{\infty}P(j)*j$$
where $P(j)$ is defined as the probability that the random walk has a span of size $j$. At this stage of time, if I can find an expression for $P(j)$, then we can all pack our bags and go home because it would be game over, I could just plug it in (and hopefully simplify it). 

From here on, I defined $a$ and $b$ according to the following diagram:
$a$ is defined as $|min(\sum_{j=1}^{N}\sum_{k=1}^{j}q_k)|$ and $b$ is defined as $ max(\sum_{j=1}^{N}\sum_{k=1}^{j}q_k)$ such that $S = a+b+1$.

Now, we can sort of find a formula for $P(j)$:
$$P(j) = \sum_{k = 0}^{j-1}G(N,k,j-k-1)$$
Where $G(n,a,b)$ is the probability that after $n$ days, Timmy has reached $a$ to the left and $b$ to the right (as depicted in the diagram above). We can further crack this formula down with the realization that:
$$G(n,a,b) = Q(n,a,b) - Q(n,a-1,b) - Q(n,a,b-1) + Q(n,a-1,b-1)$$
Where $Q(n,a,b)$ is defined as the probability that Timmy's $x$ coordinate is never less than $-a$, and never greater than $b$. In other words, Timmy is 'confined' for the $n$ days within the parameters $a$ and $b$. So the chance that Timmy actually visits $x = -a$ and $x = b$ is given by $G(n,a,b)$, and for this to be true Timmy needs to be confined by ($a,b$) (in other words $Q(n,a,b)$), but has to exceed both $Q(n,a-1,b)$ and $Q(n,a,b-1)$. (The final terms is added on in a case of inclusion-exclusion, because we over-count).
(Diagram to sort of visualize the inclusion-exclusion)

Putting everything together, we have the following equation:
$$\bar{S} = \sum_{j = 0}^{\infty}j* \sum_{k = 0}^{j-1}(Q(N,k,j - k - 1) - Q(N,k-1,j-k-1) - Q(N,k,j-k-2) + Q(N,k-1,j-k-2))$$
In words, this equation looks at all possible spans that Timmy can attain in $N$ days, then looks at the values of $a,b$ that can be used to get these spans, and sums over everything. However, I found the following rearrangement more useful:
$$\bar{S} = \sum_{a = 0}^{\infty} \sum_{b = 0}^{\infty} (a+b+1)(Q(N,a,b) - Q(N,a-1,b) - Q(N,a,b-1) + Q(N,a-1,b-1)$$
This is instead summing over $a$ and $b$. This can be seen as repeatedly asking "What is the chance that Timmy's minimum $x$ was this value, and maximum $x$ was this value?" Cool.

Step 2: Degeneration over space
I got stuck for a good while. I can remember when I made a further breakthrough. I was walking to McDonald's (I am such a healthy kid) and there's his seat on a hill that's sort of nice. I was lying down on the seat when suddenly I realized "Wait, lots of things cancel out don't they?"


The above is (roughly) what I had sketched in my notepad. Because we are summing over both $a$ and $b$, we can sort of list everything we are summing in a massive table (that extends to infinity). Each cell represents the contribution of each value of $a$ and $b$. 

As can be seen, lots of cancelling goes on. For instance, looking at the total number of $Q(N,0,0)$'s, theres $1$ from $a=0,b=0$, there's $-2$ from $a=1,b=0$, there's $-2$ from $a=0,b=-1$, and there's $3$ from $a=1,b=1$, giving a grand total of... $0*Q(N,0,0)$. In fact, a much more startling realization is that whatever values you pick for $a$ and $b$, (for instance $Q(N,x,y)$), you get a total contribution of $((x+y+1)-(x+1+y+1)-(x+y+1+1)+(x+1+y+1+1))*Q(N,x,y)$, or $0*Q(N,x,y)$. Just about now, my internal organs started failing. This was a disaster. I had felt that I was finally getting somewhere, only to find that the answer was... $0$? That's just heartbreaking. Seriously. I remember kneeling on the ground looking at the clouds, thinking "Why me?"

Shortly afterwards, I resumed walking to McDonald's, and I found the flaw in what I had done. It was to do with the fact that I was summing to infinity. I remembered my friends, I and J's voices echoing in my head: "It's bad to play with infinities (something something diverging something something)". For example, the following sum:
$$R = \sum_{j = 1}^{\infty}j - (j+1)$$
Written out, the sum looks something like this:
$$R = (1-2)+(2-3)+(3-4)+(4-5)....$$
If you pick any integer $j$ which is greater than $1$, you will have some term that adds a $j$, and another term that subtracts a $j$, in other words the sum should end up being just $1$. (there are no $2$'s, no $3$'s, no $4$'s, etc.)
BUT, it's clear that something very dodgy is going on. Each term is equal to $-1$, so effectively what we have is 
$$R = \sum_{j=1}^{\infty} (-1)$$
which is something super negative (and clearly not equal to $1$). The way I solved this problem with infinities was by bounding my sum. Currently, my sum runs from $a = 0$ to $\infty$, and $b = 0$ to $\infty$. However, for certain values of $a$ and $b$, $G(N,a,b) = 0$. These are sort of like degenerate cells. For instance, if $|a| > N$, (a reminder that $G(N,a,b)$ is the chance that Timmy visits $x = -a$ as his minimum and $x = b$ as his maximum), then $G(N,a,b) = 0$, because Timmy simply can't reach $a$ in $N$ days. Similarly, if $b > N$, $G(N,a,b) = 0$. In fact, if we draw a table like we drew last time:

For the case of $N = 4$, the above image represents which values of $a$ and $b$ give positive $G(N,a,b)$. The light blue squares mean that they are "meaningful", and the grey squares mean that they are 'degenerate matter' (I feel so cool right now, but I'm pretty sure in like a year I'll read this and think "lol thats such a dumb name"), in other words they have no bearing on the actual sum. 

So, we have to bound our sum, to something finite. The REALLY COOL THING is, that we can bound our sum however we like, as long as we bound it like within the degenerate matter. (this probably won't even make sense to me later, I'll just draw a diagram):
For instance, I could sum up all the cells within the purple boundary. This might seem like the most sensible sum, as I'm not taking any degenerate matter into account. But, I also have the option of the blue and red boundaries, because the degenerate matter doesn't actually change the sum (because each of the grey squares have a value of $0$), but can still make the sum simpler. I used my animal instincts, and picked to sum within the red boundary. 

In other words, I was limiting $a$ and $b$ to some finite value. For some reasons (that are really half-baked, so just roll with it), I wanted to make the limit of $a$ and $b$ really big. So, after taking all that into account, we have (drumroll):
$$\bar{S} = \sum_{a = 0}^{C} \sum_{b = 0}^{C} (a+b+1)(Q(N,a,b) - Q(N,a-1,b) - Q(N,a,b-1) + Q(N,a-1,b-1)$$
where $C >> N$. $C$ is just really big. Just roll with it. Now remember how lots of things cancelled? The same thing happens here. If the cell $(x,y)$ is included, then it is completely cancelled if the cells $(x+1,y)$, $(x,y+1)$, and $(x+1,y+1)$ are included. Because we picked the red boundary, suddenly our expression becomes:

$$E = 3 + 2N - 2\sum_{j=0}^{N}Q(N,j,C)$$
To explain this, feast your eyes upon this excel table (because I'm too lazy to draw anymore):
This is another example of $N = 4$. The light blue squares represent the positive valued squares. However, we know that almost all the squares completely cancel. The only values of $(a,b)$ that don't completely cancel are highlighted in yellow. Furthermore, realizing that $Q(N,c,d) = 1$ where either $c > N$ or $d > N$ (because $Q(N,x,y)$ is the chance that Timmy is bounded within $a=x$ and $b=y$, and the chance that he's bounded within $(N,N)$ or anything greater is $1$.) simplifies things. Considering just the right column of yellow squares, the top portion is $-\sum_{j=0}^{N}Q(N,C,j)$. (bloody hell I thought writing the proof was going to be easy but there's so many things I have to write, I should really learn how to write with proper math symbols and not words lol). In short, the reason is because each a yellow square at $(C,k)$ provides a $(C+k+1)*Q(N,C,k)$, but the yellow square directly underneath it provides a $-(C+k+2)*Q(N,C,k)$, in other words a net of $-Q(N,C,k)$. The bottom portion of the column is just a series of $-1$'s in a row (for much the same reasoning). The row of yellow cells on the bottom is the exact same as the column of yellow cells on the right (due to the symmetry of $a$ and $b$). The bottom right cell's positive contribution sort of 'rectifies' all the negatives.

(This is probably not going to make much sense to anyone is it lol)

Step 3: Cracking of the nuts

So what we want to find now is $Q(N,j,C)$ for $j \geq 0$. We are slowly getting somewhere. By messing around, I found another 'cracking' method (a way to decompose what we want into different things).
$Q(n,a,b)$ is equal to $0.5*Q(n-1,a+1,b) + 0.5*Q(n-1,a-1,b)$, because out of the $n$ moves that Timmy makes, the first move is either right or left. If it's right, the chance that overall Timmy is constrained within $(a,b)$ is going to be the half times the chance that within $n-1$ days that he is constrained within $(a+1,b-1)$. The same applies if Timmy moves left on the first day. These two outcomes are shown by the purple/red lines. 

After decomposing the whole lot bit by bit, what we end up with is
$$E = 2 + \sum_{j=1}^{N-1}Q(j,0,C)$$
(Here we use the fact that because $C >> N$, then $C - 1 = C$ pretty much. In essence, we can choose $C$ however big we like, so it won't have any bearing on our sum.)

Step 4: Analyzing the Truncated Pascal

Lets take a moment to think of the significance of $Q(j,0,C)$. Pretty much, this expression is the probability that in $j$ days, Timmy never goes to the left of his kennel (because $a$ is $0$). We can represent this information in a 'truncated Pascal Triangle':

The 'truncated Pascal triangle' is a representation of the paths that Timmy can take, if he is never to go left of his kennel. (hence $x \geq 0$). $j$ in the table represents the number of moves that Timmy makes. Pretty much it's truncated, except it works just as a normal Pascal triangle works. The numbers represent how many ways there are of Timmy arriving at that particular $x$ coordinate after $j$ days. What's interesting to us however is the probability that after $j$ days Timmy has not moved left of his kennel, i.e. we are interested (indirectly?) in the sum of each row (shown on the right). 

Looking at those numbers invokes a sense of awe within me. Because these are all numbers found on the PASCAL'S TRIANGLE!!! (the normal one). To be precise, the sum for $j = n$ will be $n \choose {\lfloor \frac{n}{2} \rfloor}$. This is all well and good, but finding a reason for this match up is actually quite hard. In fact, I pretty much couldn't find no reason for it. It's almost like I found a KFC box on the ground, except it was filled with rocks. My heart was crushed. 

So here I was, racking my brains for some way to determine the sum for any value of $j$. (I actually came up with this method a long time ago, but it was a completely idiotic method so I was like "haha nah"). Basically, from $j = 0$ to $j = 1$, there's only one path (so the sum doesn't change). From $j = 1$ to $j = 2$, the path splits into two, so the new sum is twice the old sum. From $j = 2$ to $j = 3$, one of the paths only has one route to take, and one of the paths has two routes to take. If I was incredibly naive, I'd say that $S_{new} = \frac{2+1}{2} S_{old}$ where $S_{new}$ is the new sum and $S_{old}$ is the old sum. For $j = 2$ to $j = 3$, this actually works. Then for $j = 3$ to $j = 4$, again, all the paths split into two, so its no surprise that the new sum is twice the old sum. For $j = 4$ to $j = 5$, one of the endpoints only has one choice (so as not to go to $x = -1$), but all the other endpoints have two choices respectively. Using my incredibly naive method, we would expect $S_{new} = \frac{2+2+1}{2}S_{old}$. AND IT WORKS. In fact, this incredibly naive definition works for all values of $j$ I tested. 

Now, this is incredibly strange. The transitions from $j = odd$ to $j = even$, where the new sum is twice the old, is nothing strange. That's expected. But the method I was using for the transitions from $j = even$ to $j = odd$ was just completely nuts. The only way it would work is if (for some reason) the first term in each row where $j = even$ is the average of the values of the entire row. It's clear from the diagram that this is the case for the values of $j$ shown. (for instance, for $j = 6$, the average of the row is $\frac{SUM}{4} = 5$, and the first value is $5$). So, if I could prove that the first value of each row for $j = even$ is the average of the values of the entire row, I could use my method to find the Sums, then find the probabilities, then I could find the span and I would be a very happy man. 

I thought I'd try my hand at induction (simple induction, where we assume true for $j = k$ and prove true for $j = k+2$). Firstly, some notation. $p_{f,g}$ is the $g$th number on the $j = f$ row. From the table given, it is evident that the statement is true for $j = 2$. Assuming true for $j = k$, we have that:
$$p_{j,1} = \frac{p_{j,2}+p_{j,3}+...p_{j,0.5j+1}}{0.5*j}$$
Now we wish to prove statement for $j = k+2$ (because we are only interested in $j = even$)
$$RTP: p_{j+2,1}= \frac{p_{j+2,2}+p_{j+2,3}+...p_{j+2,0.5j+2}}{0.5*j+1}$$
Now, from the pascal's triangle, we can observe that:
$$p_{j+2,1} = p_{j,1} + p_{j,2}$$
and for $k > 1$:
$$p_{j+2,k} = p_{j,k-1} + 2p_{j,k} + p_{j,k+1}$$
Using these relationships, (and using our assumption) we finally arrive at:
$$RTP: p_{j,1} = \frac{j+4}{3j}p_{j,2}$$
So now, we are nearing the end. All we have to is prove this final statement, and we have all the pieces ready. It's been a long road, but we are nearly there. 

Step 5: The Final Destination

So at this point of time, what we want is a method to relate $p_{j,1}$ to $p_{j,2}$. Luckily, there's a method that does exactly that. $p_{j,1}$ can be understood as the number of unique paths that Timmy could take from one corner of a square to the opposite corner without crossing the diagonal joining the corners, as shown here:

The purple line represents what Timmy must not cross, and the red is an example path for Timmy. 

Evidently, the total number of paths that Timmy can take to get to the other corner is $j \choose  \frac{j}{2}$.  What we want to do is separate the paths that strictly stay above the purple path from those that pass below the purple path. The tactic we use is this. Suppose we have a path that drops below the purple line. That means at some point, it will venture to the right of the purple line. Now, reflect all the moves one move after Timmy has crossed the purple line. 

For instance, this red path crosses the purple line along it's journey. We let Timmy take one step into the beyond, and then reflect all his subsequent moves, so that if he were to move right make him move up instead, and if he were to move up then move right instead. We can easily see that all such paths will end up at a point one below and one to the right of the intended corner. From the facts: (1) All paths that cross the purple line can be flipped to produce a path that ends at this new point (2) All paths that go to the new point can be generated by flipping a path that crosses the purple line (3) All paths that cross the purple line, when inverted, produce a unique path, we can conclude that the number of paths that cross the purple line is equal to the number of paths that reach the alternate end point, namely $j \choose {\frac{j}{2}-1}$

Using this logic, we can get an expression for $p_{j,1}$:
$$p_{j,1} = j \choose \frac{j}{2} - j \choose {\frac{j}{2}-1}$$
We can use very similar logic to get an expression for $p_{j,2}$:
$$p_{j,2} = j \choose {\frac{j}{2}-1} - j \choose {\frac{j}{2}-2}$$
Combining these two formulas, we can find the relationship between $p_{j,1}$ and $p_{j,2}$, and lo and behold:
$$p_{j,1} = \frac{j+4}{3j}p_{j,2}$$
Bam. We find exactly what we need to prove the induction, that the beginning of each important row of the truncated pascal is the average of the entire row. From here on, life is a breeze. We just throw everything together to get a formula. There are heaps of ways to express the formula. The most comprehensive is:
$$\bar{S} = 2 + \sum_{j = 1}^{N-1} j \choose {\lfloor \frac{j}{2} \rfloor} * \frac{1}{2^j}$$
 but the one I like the most is:
$$\bar{S} = 2 + 2(\frac{1}{2} + \frac{1*3}{2*4} + \frac{1*3*5}{2*4*6} + ... + \frac{1*3*5*...*(N-2)}{2*4*6*...*(N-1)})$$ 
for odd values of $N$. 

I was going to read over what I had written, but I'm burnt out. 
The prediction is in green, a test is in blue. As can be seen, it pretty much fits exactly. This is a plot of $\bar{S}$ against $N$

It shouldn't converge, but I'll leave the proving of that to another day.









Sunday, 10 January 2016

The worst day in the history of worst days

-So I mean nobody is going to read this anyway except for friends, but I will anonymize everything anyway, including names and places and everything. From this point onward, I shall be known as P (for Pete Patterson, because that is my real name)-

So the other day, I had probably the worst day in the history of worst days. Actually, it wasn't really THAT bad, but all the tiny instances of bad-ness just pile up to give an overall impression of bad. It was such a bad day, that it's pretty funny, which is why I'm writing this up.

A few days ago, me and K (a good friend) decided that we should visit D (a capital city). Every year, a nice camp is held at D for a few weeks, and K and I had attended the camp of 2015. We decided to visit primarily to thank the camp's organizer, M, who had helped us out a lot recently. We also wanted to reunite with some friends who had also attended the 2015 camp, who would be organizers for the 2016 camp. Now, M did mention in the 2015 camp that if we wanted to drop in to the camp and say hi that we should notify M before we arrive. But the camp wasn't actually due to start for a few days (M just arrived early), so K and I rationalized that it should all be good. haha
(P is me, K is good friend, and we are visiting M)

We had another friend, L, who also attended the 2015 camp, but who lived in D. The night before we were planning to visit D, we messaged L, and said "Hey, guess what! We are coming to visit tomorrow! Can you show us around D for a bit so we can have fun?" It turned out that L wouldn't be in town on that day. In fact, he would be visiting E, where K and I come from. That was just heartbreaking. At that moment I thought "Dang, our plan is sort of half-ruined". But the terror was only just beginning.

At 4:30 AM on the fated day, Airplanes by B.O.B. started playing on my phone as an alarm. I practically fell out of bed, stumbled to the shower and flushed myself into a state of semi-wakefulness. 4:30 AM is literally the earliest I have ever had to get up (probably not actually, I might just be forgetting some day). ANYWAY, it was super early, but I was super pumped because today because I would be meeting friends, thanking M, going back to D. Life was looking pretty good, despite the extreme lethargy that permeated my carbon-based frame. I soon met up with K after catching a train, and we were just about ready to ske-daddle and catch a 3 hour bus to D.
"Wait a second, K, I need to buy a card for M first"
Well of course, the Newsagent didn't have any blank cards, or any thank you cards, or any cardboard. Well, what could I expect? After all, today is the worst day in the history of worst days.
"#YOLO bro, I'll just make something on the bus, I brought some paper in my bag."
The card I made wasn't actually that dodgy. Well it was pretty dodgy. It wasn't very rectangular, the writing was kinked because of the bumpy bus, and it was generally not very well done. But it was still a half-respectable card.

Nothing else to draw, so I drew the lady sitting in front of us who told us to shush

After I finished my card, however, we had a lot of time to kill. Our bus would only reach D in three hours, so we had a lot of time to kill. K came up with the great idea that we should swap our phones and start messaging random people. My internal monologue said something along the lines of "haha that's pretty funny, OK lets do it". I scrolled through K's list of friends, looking for potential targets. I finally locked on, and began my K-impersonation. I must have been really good at impersonating K, because not many people actually realized that I wasn't K. The deed done, I looked over at K.
Pete To Unknown Person 1: Follow your dreams, stay true to your heart :,)
Pete To Unknown Person 2: Follow your dreams, stay true to your heart :,)
Pete To Unknown Person 3: Follow your dreams, stay true to your heart :,)
Pete To Unknown Person 4: Follow your dreams, stay true to your heart :,)
I swear one of my internal organs ruptured as I saw the screen. I like message <5 people in total, this sudden explosion of messages to random people that I've never talked to goes against the very fibres of my being. (Luckily people caught on pretty soon). Anyway, we whiled away the time like that. Our anticipation for the day started growing as the bus neared D.

Soon we arrived. We walked with haste toward the building where the camp is held, eager to be reunited with our friends and our leaders. You could almost say we frolicked our way over. We were feeling pretty good at this moment. Of course, this didn't last for very long, because this is the worst day in the history of worst days. But for a brief few minutes, the anticipation bubbled in our guts with every step. We got lost on the way, but that happens all the time. We eventually made it to the building where the camp is held.
Dang I look so deep
Wait wait wait so I anonymized everyone's names but I'm including pictures
wait was there even a point
wait what is life 
yolo whatever. As Macbeth rightfully said:
I am in blood stepped in so far that, should I wade no more, returning were as tedious as go o'er.

We arrived at the place where the camp is held. Heart beating 246. I shrunk behind K as he boldly entered the room. 
"Hey M! Long time no see!" K exclaimed happily. 
Because that day was the worst day in the history of worst days, of course M was not actually there. K was just trolling me as he always does. In fact, M was nowhere to be found in the regular haunts. We decided to go and wait it out in the Psychology Ward. It was actually quite a pleasant place, there were two chairs (as if specifically designed and placed for us) by a shelf of free books. Free is a word I like to hear, even if it's for Psychology books. 
Didn't know Psychologists needed to know so much Statistics. Like there's whole tables of standard integrals and log tables and all of that. 

A bright light suddenly illuminated our minds, as we realized that maybe we would find M at the residential colleges. After all, the residential colleges was where the food was at, and everybody liked food. So after spending about an hour dawdling at the Psychology place, we straggled over to the residential hall. The fire in our spirits was slightly dimmed, but still burning alive. Of course, because it was the worst day in the history of worst days, nobody was there. So we just sat around, waiting for Godot. At this point of time, we were getting slightly worried. We had heard that people were arriving at 11. "But what if they meant 11pm, not 11am?" an insidious whisper whispered. Pushing such nasty thoughts to the bottom of our brains, we entertained ourselves once again by taking each others phones and messaging random people. Because of all this random messaging, our batteries were running low (THIS IS IMPORTANT).

Anyhoo, my eyes were like pretty darn bad. I was swapping over from contacts to glasses, long story short I couldn't see anything more than ~15cm away from my face. Halfway through messaging, K suddenly taps me on the shoulder. "Pete!" he said "It's them! It's M and the rest of the bunch!"!! My heart was suddenly beating 246. It was great that we weren't alone anymore, but.. but... I hadn't really prepared for this moment. I didn't know what to say. "Are you really sure, K? Like, really really sure? Beyond a doubt?" I stared vaguely in the direction K had been pointing, but all I could see was a indiscriminate skin-colored blob. "Yes" K replied succinctly. "But are you really realllllly sure?" I asked again.  "Yes" was the curt reply I got. We edged up towards M, (I sorta hid in the shadow of K) and we greeted them. Like really awkwardly. If sitting with an acquaintance for an hour in silence was rated as a 7/10 awkwardness, and somehow mistaking some random person as your friend and feeling his butt for a good ten seconds as 9/10 awkwardness, this easily surpassed 10^100!/10 awkward it was just that awkward. We sort of just gave our cards, laughed a little bit. Looked around. Laughed a little more. I was practically dying of cancer, my internal organs were failing one by one.
This is what M looked like to me. 

Thankfully, we were saved by the arrival of some comrades in arms (fellow 2015 campers). "OHH! PETE AND K! What a surprise!" S said, with extreme confidence. It was slightly better with more company. After some time, we dispersed a little, and somehow we all managed to get crowded into S's room. Because of our gallivanting on instant messaging, K+me's phones' batteries' were both suffering pretty bad (my english right now is suffering pretty bad too). K suddenly said "Oh wait, I brought a charger!" and proceeded to leave his phone in S's room charging. "We'll just come back and get it later, someone remind me lol".
IMPORTANT CONVERSATION:
K: My goal for today is not to leave my phone here!!
Me: Haha, that's a pretty low aspiration to have!! Haha! Ha! Hahaha!

haha

So we congregated once more in the place where all people meet. We were sort of standing around, discussing what food to get. Me and K were just standing there, sort of just hanging around, not doing very much at all. After some time it seemed we had reached some sort of a consensus (Nandos? not sure). We started walking North for a bit. Me and K somehow ended up at the back of the pack, just following along. As we break into the open, I notice that we are in the carpark. My terribad eyes pick out the blurry figures of several people piling into two cars, and the figure of M swooping in our direction. I turn to K. "Oh, **** **** ******* they taking the car." It wouldn't even have been that bad, except because it was the worst day in the history of worst days, it started raining at that exact moment. M shook our hands.
"Thanks for dropping by, drop by again if you have the time!"
And just like that, they sped off into the rain. Me and K were standing there, beneath a broken umbrella. TRUTH BE TOLD, they only did have two cars we weren't going to fit anyway, but we had pressing issue on our hands 1) Where do we get food 2) its raining pretty hard and 3) K's phone is still in S's room and we just got separated. This was not going good.


Right about now I was questioning my life choices


We made our minds up, as pure adventurers we would take the hard road and struggle our way to Canberra. Needless to say, we got drenched. If the average amount of water consumed by the United States in one year was 1 joshe of water (a new unit), then we probably absorbed 10 joshes of water just walking to Canberra. The water content absorbed by our pants was probably heavier than the pants itself. Dripping wet, we struggled through the streets of Canberra, trying to find food. We soon found a McDonalds, (well K found it, I couldn't really see anything). K suddenly had a brilliant idea. "PETE!" he said. "WE CAN MAKE OUR OWN BURGERS! These burgers will be the ONLY GOOD THING that happened to us today!" Well I'd never done it before, but at this stage I was ready for anything. I opened up the menu, and just bloody added everything to my burger; eggs, lettuce, beetroot, the whole lot. Next it was K's turn. As the plagiarist he is, he opened up the 'chef's suggestions' and picked one of those. Then he tried to change the toppings a little bit. He added three jalapenos, and three long pickles. I was too tired and worn down to judge his taste, so we went and paid and sat down at the table. (we got a free coke though, which was good).

Of course, because that day was the worst day in the history of worst days, something went wrong with the burgers. With K's burger, to be precise. MINE was fine (thank the lord), and I happily chowed down on it.


Something seems... Off about this packaging...

On further inspection, K's burger comprised of the following:
 - Two Buns
 - A beef patty
 - Three jalapenos
 - Three long pickles
SOMEHOW, ALL HIS OTHER STUFF GOT DELETED, and he was left with a jalapeno pickle burger.
Poor chap.
Srs.
Pooor chap.


K: I'll go get some tomato sauce for my burger from the counter

After we finished, our problems still weren't solved. We needed to get K's phone from S's room. However, there were several complications:
1) I had a new phone, so I didn't have nobodies numbers
2) My phone (because of K) was quickly running out of battery, and I needed it to last until at least midnight (when our bus was scheduled to arrive in Sydney)
After some more careful deliberations, K managed to get S's number from Y (another 2015 camp acquaintance) online, which was super good. At this point of time, we had a while to while away, not enough time to visit anything special (like Questacon, which is apparently good but I've never been), and it was too rainy to climb Black Mountain (which L suggested we do). In the end, we just struggled our way back to the residential hall, to wait.

At the hall, we managed to persuade some people to let us into the piano room to while away the hours. Nothing really eventful happened, apart from my ever decreasing phone battery. There soon came a time when we were greeted once more by S, and we could retrieve K's phone. Suddenly, all our worries came undone. It had been a crap day, but we were finally safe from any more problems! Haha! Yes! haha haha

After retrieving K's phone from S's room, we returned to the piano room (because piano is life(though not my life(though I wish it was))) and boogied a bit for a while more. We had the door closed, and life was really peaceful. After all the stress my heart had gone through during the day, I had finally found 42, I had finally found peace within myself. S and J had mentioned a 6:30 deadline they had to meet, but that seemed so long ago, and what was 6:30 but a number? And what is a number but a mathematical abstraction? It held no reality in my heart, for I was one with the birds.

*knock knock knock*

Oh. Oh. HRuuruhRHURmmmmmmmmmmmm mm mmm. Hmmmmmmmm. I watched as the brave man known as K stood, and opened the door. I sort of knew what was coming.
Twas M. Now, my memory of this part of the story is sort of bodgy, everything is in a haze (perhaps because my brain was failing at that particular moment in time), but it went something like this.
"S, J, A! WHAT? 6:30. OUT!"
Me and K stood there, like spongebob and patrick, frozen under the pressure of the ocean's weight.
Cold nothingness. I looked at K's face, he was stoic. It would have been funny, had it not been us getting in trouble. Time seemed to slow, as if a disturbance in the force were warping our space-time trajectories. I think it's important to note now that everything that happened was K and I's fault, I mean M specifically mentioned that we should contact them if we were visiting and we didn't (lol) because we thought a surprise is always nice once in a while. Long story short, M pretty much told us if we came again he'd kick us out, but for now we could hang around in the piano room.

Silence. Me and K looked each other in the eye, sat down at the business table, and thought together:
"My, what a day. What a day." What else could we expect from the worst day in the history of worst days? Literally nothing could get worse, it was just impossi-

*knock knock knock*

Y*#&(%#W&*(#%W&*(*W%#&*%W#&
T: "M may have let you stay, but I'm going to have to kick you out, sorrynotsorry."

~Cue Green Day~

At this point, our day was about as bad as bad can be. We straggled back to Canberra to get food and leave. Of course, because it was the worst day in the history of worst days, when we tried to get Japanese noodles, they said "you'll have to wait 20 mins", which would make us miss our bus. We ended up getting more McDonalds. Finally, when we got on the bus, it was pure bliss, because we knew we were finally safe (for realzies)

the end
OK my english is pretty tomato-like throughout this whole spiel, but yea after going through applications for unis I feel a bit braindead