Tuesday, April 27, 2010

Special Relativity

Ever since my high school physics class, special relativity has always bugged me. I thought I understood the concept, and I was able to work through the thought experiments presented by my teacher, but I always had one in my head that bugged me. Recently, I decided to work out the problem on paper, and resolved my issue! Yay! I will try to explain my findings here. My explanation may be completely off-base, but the concepts and results I talk about are definitely correct (take your disagreements up with Einstein!).

In the text below, I will try to introduce the problem, but that is going to require some background. I will attempt to give it; if it isn't coherent, you'll have to read a real book about it. I promise I'll do my best, but even really clever physicists can't really explain this stuff in a short post, so my task seems a little daunting.

To understand special relativity, you have to understand that the speed of light (conveniently denominated c)is constant. The speed of light is the speed of light, no matter the reference frame. That's a little peculiar, because in traditional physics, the reference frame is quite important. If I throw my luggage down from my moving train to my sister on the platform, she perceives the velocity of the luggage to be the speed of my throw plus the speed of the train.
Is this true for light? In other words, if I kindly decide to shine a flashlight at my sister instead, does she measure the photons moving at c plus the speed of the train? Before Einstein, physicists believed that she would. In truth, she does not.

If you find this intuitively wrong and creepy, then at least you've understood what I'm saying. To make sure you understand the enormity of the situation, imagine that the train is traveling at .99c. I can measure the photons coming out of my flashlight at c. My sister measures the photons coming at her at c. What the heck is going on here?

It turns out that this result can be explained via time and length dilation. But what are time and length dilation, you ask? Let's focus on time dilation, and leave length dilation to a more complete text.

One of the implications of special relativity is that the faster you move, the slower time moves. The best way to understand why this happens is to understand that time is a dimension, just like the three we're used to (x, y and z, i.e., length, width, and height). In other words, as I'm sitting here typing, I'm stationary in the usual three dimensions, but moving through the time dimension. Einstein suggested that everything moves through the four dimensions at the speed of light. Thus, I am typically traveling through the time dimension at the speed of light, while staying constant in the usual three dimensions. Due to conservation of momentum, if I want to move in some direction, I have to be moving through the time dimension slower, in order to keep moving through all four at the speed of light.

If you accept that as true, then the dilation of time through speed makes perfect sense. If I'm on a train moving at .99c, then I can't be moving through the time dimension as fast as if I'm stationary. You'll have to accept my word that at .99c, both time and length are dilated by a factor of 10. Or, you can look up the Lorentz equations for time and length dilation, and calculate the result yourself. Either way, let's move on and figure out the implications!

At this point, my explanation has left a lot of room for confusion, so let me try to specify what I'm talking about. When I say that time is dilated by a factor of 10 at .99c, I don't mean that on the train, I perceive my life to be going by at 1/10th normal speed. Since the train is moving at a constant speed, I can rationally argue that I'm not moving at all. Time is moving at the speed I expect. To my sister on the platform, however, I'm moving at .99c, and my time is moving at 1/10th of the speed of hers. How can both of these experienced realities be true?

In fact, the confusion goes further. As I already established, to me and everyone else on the train, time is moving normally, because we are at rest. When I look down at the platform, I see it moving by me at .99c. Thus, I must see my sister moving through time at 1/10th the normal rate. While this result seems unbelievable, it actually resolves the question of how light always travels at a constant speed.

Imagine that I'm on the train moving .99c, and I shoot one photon in the same direction. Einstein tells me that I must measure the photon moving at c, because the speed of light is always constant. My sister on the platform sees me go by on the train, and measures the photon moving at c. How can this possibly be?

First, let's imagine that I measure how far away the photon is from me, one second after I shoot it. Since the speed of light is always c, I measure the photon as being 186,000 miles away. What does my sister measure? Since the photon always moves at the speed of light, after one second, the photon moves 186,000 miles away from her. But the train is also moving at .99c, so in that time, it has moved .99*186,000 miles away from her. Effectively, she should see the light as 1,860 miles away from the train. So which is it- 186,000 or 1,860?

The key is that my sister times and measures in her reference frame. When my sister measures the photon as 1860 miles away from my train, since my reference frame is length dilated, those 1,860 miles correspond to 18,600 miles in my frame. Furthermore, since she measured after 1 of her seconds, she sees only 1/10th of a second has elapsed on the train. After 1/10th of a second at the speed of light, the photon should be 18,600 miles away.

Don't get me wrong, I'm happy that I haven't come up with a contradiction to one of the pillars of modern physics. But this result is still pretty weird, at least to me. To my sister, my time frame is slowed by a factor of 10. To me, time is moving normally, and since my sister is the one moving at .99c, her time frame is slowed by a factor of 10. So if we reverse the whole observation frame of this thought experiment, when I measure my photon after 1 second, I see that only 1/10th of a second has elapsed in my sister's time frame. But before, we were saying that when she measures the photon, it looks like 1/10th of a second has elapsed in the train reference frame. This brain-melting result just illustrates that time is relative. There is no absolutely correct notion of when events occur: time depends on frames of reference. Since everybody not experiencing acceleration has an equal claim to be in motion, everybody has a right to talk about how fast or slow time is moving.

This is merely one of the many strange implications of special relativity. I hope it made a bit of sense.

Monday, March 23, 2009

Oops...

That's what I get for being lazy with writing. I was beaten to the punch by this guy: http://scobleizer.com/2009/03/21/why-facebook-has-never-listened-and-why-it-definitely-wont-start-now/


And I'm sure by many others...Oh well :)

On Optimization...application

This is Part Two of my optimization posts: the application.


A lot of people have been complaining about the Facebook redesign. In fact, there are so many complaints coming in (one "study" claims 90%, but the group was self-selected, so the numbers are useless) that some internet folk have stated their astonishment that Facebook would do such a radical re-design without even considering their users' tastes through A/B testing (like Amazon uses).

I must say, I find this chatter quite silly. Admittedly, I have no idea what's going on in Facebook HQ, but I do know that they make an amazing product*, and I'm confident that they know exactly what they're doing, whether they think that directly pleases the users or not. Wait, what?

*(This asterisk style comes from JoePo. What can I say? He's a genius. I think I'll be using it, because it makes my sentences less confusing- I can expound on a topic later, but not too-far-end-of-the-page later.) I don't spend a lot of time on Facebook, but every time I go exploring around the site, I find another feature implemented really, really well. Those guys are good.


There, I said it. Doing what the users want does not translate to ultimate success. To connect this to Optimization, sites that do exactly what the users want right this minute are finding the local maximum of their site's success. They look directly to the right, and they see the graph peaks. They look left, and the site hits a valley. So they go right, and they're at the highest point as far as the eye can see, and everyone is happy. But...they're not at the global max, and they are thus not as successful as they could be.

Sites like Facebook determine what is best for the site, not solely based on user polling, and they implement it. Sure, they take back some mistakes (certain News Feed and privacy issues come to mind) quickly based on user reaction, but the overall direction of the site stays the same. Veterans of Facebook will tell you, this is hardly the first time that "everyone" using Facebook hated the redesign, and yet, the site continues to grow.

The site continues to grow because Facebook is seeking the global maximum of social networking sites. Through opening the site to the general public (the jury's still out on that one, in my opinion), and through emphasis on presenting fresh content every visit with the News Feed (this is a huge win for them), Facebook is going where they feel will lead to the most success possible.

Of course, this does not always work out. Like Apple, if Facebook's strategy of defining boldly what the consumer gets is to work, the theory behind their moves must be sound. So far, it's working out pretty well, but that doesn't mean it always will.

But imagine this: if, 5 years ago, MySpace polled their users endlessly about what features they wanted, and implemented everything they wanted, do you think the site would've ended up like Facebook (in the end, a much more successful site)? No way. MySpace would've found their local maximum (they probably did that a while ago...), and continued to serve their users the way they thought best. Meanwhile, getting back to the math post, just beyond their detail level, an enticing, new, global maximum was lurking, and they never achieved it.


In short, I think Facebook really does know what they're doing. I'm still not 100% convinced on their money-making schemes (I don't think advertising is working as well as they thought), but I think that, in the end, this new design will end up driving more traffic (and thus, more profit) to them. Just like the other re-designs, there will be lots of critiscm, followed by more and more people addicted to Facebook ;).

On Optimization...

This is part one of two on mathematical optimization. Part two will cover an interesting application of this stuff. You may want to skip to part two ;)

I'm in a math class called Optimization this semester. Essentially, we study what methods the computer (in our case, Mathematica) uses to solve optimization problems.

An optimization problem can be as simple as deciding which gas station to go to, with variables of distance and price, or as complex as the math behind Obama's economic policy. At first glance, these problems seem very simple to solve, and indeed, for problems like the gas station choice, they can be solved with naive methods. As always, though, this math topic is more complicated than it seems.

Imagine if you were a particularly mathematically inclined high school senior deciding which college to go to. After your initial college visits, you've taken detailed notes on each college, ranging from the food services (Bowdoin is consistently in the top 2 nationwide) and dorm life to grad school acceptance rates and student:faculty ratio. Further imagine that all of these factors (some quite subjective) can be assigned numerical values. Then to decide which college is best for you, you write an optimization problem that assigns weights (modeled by constraints such as food >= 8.0) to each variable, according to your personal taste.

By the time you're done, there may be 10, 15, 20 variables! And to think, this problem is downright tame compared to most optimization problems (which can have thousands of variables!). While a normal high school student surely runs a version of this very same optimization problem in their heads while choosing a college, you will settle for nothing less than the exact correct college. But how? Can't we just play around with the variables until we get the right answer? Technically, yes, but this is not as easy as approximating distance and price of gas stations. With this sort of complex optimization problem, changing one variable may have an influence on the others, and before you know it, your head is aching from all the possible combinations of variables. (Mathematica to the rescue!!)

But seriously, Mathematica is a great tool for solving optimization problems, but how does it work? That, dear reader, is far too much detail for this already lengthy post. The point I'm getting at here is that some problems can't be solved by tinkering with variables one at a time, because once you have a complicated problem to solve, changing one variable can change the entire nature of the problem. In addition, with multiple variables, there are just too many things to tinker with. For a one variable problem, I could simply graph the function and find the low spot, right? Sure! The formal way to solve this (this is an important distinction from just "using the picture") is to find all the places where the derivative (and thus, slope) equals zero. If my minimizer isn't one of these points, then the slope at my minimizer has some value, like 1, which means I can continue along my function and find a lower point...thus, I didn't really find a minimizer.

For a two variable problem, I can still draw a graph, but I have to do it in 3D. For a three variable problem...uh oh. In fact, even two variable problems can be hard, if the function is ugly enough.

So, for the college optimization problem, we start to see why we needed to move away from simply following the graph to the low point in the example above. I can not draw a graph in 20 dimensions (hey, I'm not a visual arts major!), but even if I could, how exactly would I trace the function along and find the low point? This is a problem even in a 2 variable problem (represented as a 3D graph). I can poke around the graph, zoom in, and perhaps find a spot where the function is minimized locally. But how can I be sure that that is the global minimizer? I really can't, unless I check every part of the graph! Not only is this tedious, it's quite impossible- functions have infinite resolution by definition, so you can't just zoom in enough that the function stops changing. If the function is complex enough, there can be all sorts of crazy behavior lying just below your current detail level.

Thus, we need a symbolic way of solving this problem, akin to solving the derivative function in the one variable example. That way, no matter how crazy the function is, we don't have to go zooming in and panning around forever- we just get the answers. Unfortunately, the methods for higher order (meaning more variables) functions are not as easy.


If this post made very little sense or seems to have no connection to life, go ahead and read part two, where I will attempt to connect these topics to internet companies.

Wednesday, November 26, 2008

A Program

After seeing this post by Kottke, I decided that a logical way to spend my time in the middle of studying for midterms would be to create the program requested!

Of course, the author had already found people to code it for him, but I thought it would be an easy way to play with some python.

Here's the code. Feel free to use it for whatever, just let me know if you do.

Depending on my time and effort (what doesn't?), I may modify this program to be more sentient. We'll see.

Happy Thanksgiving!

Friday, October 31, 2008

Deal or No Deal?

Don't worry, I haven't yet sold out to The Man, so this isn't an advertisement for this awful show (read up if you haven't heard about it). Rather, I wanted to share this video, which is currently making the rounds on the internets.

I'll save you the time of reading the comments on this video from digg, reddit, etc...they basically sum to "OMG that guy is such a fool!!"

Of course, I have to agree. However, I feel that this situation opens up an interesting psychological question. My parents watch Deal or No Deal on occasion, and they always complain of "stupid" people who get "too greedy". I always laugh at this, because due to the nature of the game, you're really being greedy as soon as you eliminate a briefcase. (In fact, this judgment has been passed on many others, e.g., the characters in the movie 21. Some say when viewing the movie, "why didn't they just quit while they were ahead?!?!?")

Allow me to explain: Deal or No Deal is a game of 100% luck. There is absolutely no strategy involved in picking which case you want to be eliminated, nor is there a way to "outsmart" the bank. Interestingly, in my one quick viewing of the show, I thought that the bank offer was a straight average of the remaining cases.
As it turns out, the average is weighted, and as the game progresses, the average approaches the straight average. In other words, the bank will offer a "bad" deal in the beginning of the game, and a relatively "good" deal at the end.

Anyway, back to the story. I always find it funny when people judge the decisions of people on the show, saying something like "I can't believe it! Just take the deal and walk away! You have (insert amount here) already!"

Of course, this is not sound logic. At what point is it silly to not take the deal? Since each deal is worse than a straight average of the remaining cases, is it ever really silly? Of course, the deal is worse because it is a balanced alternative to risk. But I digress- imagine this:

play while cases > 0:
------>if logicalToDeal then return
------>eliminate case x with $y in it. //This raises/lowers my overall average, and thus, my bank deal.

At what point does logicalToDeal become true?
If you imagine playing a game, what determines the value of logicalToDeal?

Probably the only way to play the game is similar to generic smart money strategies: set a limit and stick to it. I will determine a money value X, where X is enough to make the game worthwhile. If I ever get a bank deal >= X, then I will stop playing.

Two things:
1) What is X?
2) What if you never reach X?

#1 is interesting in this case because you cannot lose money in this game. Unlike setting a limit for yourself at a casino, where you really have to set both an upper and lower bound, in Deal or No Deal, the worst that can happen is you walk away with the briefcase with the least amount of money. For sure, that would be a disappointment relative to what you could've won, but nothing truly bad will happen if you play too risky.
(This goes back to the kids in 21- at what point should they just have walked away?)

My overall point is that it is meaningless to simply state that one is a fool for not making a deal, walking away, etc. There is no set point where one path becomes more logical than the other in games like these, so the point where one should give up is mostly arbitrary and personal.

PS: wouldn't it be nice to be a contestant on this show? You don't have to have any intelligence, because there is no possible way to strategize, and you always win money. Sounds awesome!