Posts Tagged ‘Algorithms’

End of Fourth Week

It’s getting a little too close to time to leave for me to do a whole post, I think, but I did want to put out my travel details so that people would know where I am when, so here goes.

Itinerary:

Bus:
Barcelona to Girona Airport
Departs at 8:30am – Arrives at 10:00am

Flight:
Girona (GRO) to London Luton (LTN)
Flight FR3769 – Sat, June 06 – Departs at 11:55am – Arrives at 1:15pm

Hostel:
St. Christopher’s Inn – Hammersmith
Check in: Sat, June 06 – Check out: Tues, June 09

Train:
London Euston Station to Liverpool Lime Street Station
Tues, June 09 – Departs at 8:07pm – Arrives at 10:20pm

Hostel:
Hatter’s Liverpool
Check in: Tues, June 09 – Check out: Thurs, June 11

Flight:
Liverpool (LPL) to Dublin (DUB)
Flight FR443 – Thurs, June 11 – Departs at 6:30am – Arrives at 7:20am

Hostel:
Jacob’s Inn
Check in: Thurs, June 11 – Check out: Sun, June 14

Flight:
Dublin (DUB) to Reus (REU)
Flight FR1116 – Sun, June 14 – Departs at 12:15pm – Arrives at 3:45pm

So, I’ve been making a lot of chocolate milk this week. I got a bottle of the Cacaolat brand chocolate milk, and I really enjoyed it. It’s more chocolatey than typical U.S. brands, but kind of expensive for the amount of it you got. So, instead, I’ve started getting UHT white milk, which isn’t initially chilled, can sit on a shelf for up to a few weeks, and is cheaper, and I got a kilo (2.2lbs) of chocolate Cacaolat brand powder. The milk is just as good as the bottled chocolate milk, and I get a lot more of it for significantly less money. Unfortunately, the chocolate milk is so delicious that I went through a liter of it in two days, so I’ll probably have to back down on that a bit.

We went to McDonald’s this week, too. It was interesting. I’ve since seen a few more McDonald’s (though still only eaten there the once), and they’re actually nice on the inside, about on par with typical American Starbucks. We walked by the National Theater on the way back. I’d definitely be interested in seeing something there. It’s a very nice, elegant building.

My entrepreneurship class is going pretty well at the moment. I hope we work on some more of our companies and products stuff over the break, but I have some guess that we probably won’t. It’s really excited me to want to start my own company after I graduate, so I suppose I’ll have to take that option into account once I get back home.

We started covering the Fourier Transform in algorithms, and it looks pretty neat and relatively useful. I couldn’t quite execute the algorithm after just the lecture so far, but I’m looking forward to forward to hearing some more about it and how it works. The gist is, as we’ve covered it, that you can somewhat easily go from a set of points to a polynomial and back. I probably won’t go into it in the kind of detail that I covered some of the other algorithms because it’s so prolific, you could probably understand enough of it from a source like Wikipedia.

In Computational Photography, we covered High Dynamic Range (HDR) imaging. First, some examples. The idea here is that there is a lot of color lost in images, especially outdoor ones. Regions of an image come out too bright (super white) or too dark (super black) because of various reasons involving your lighting. If you want to get all the color in all the regions, then, you have to take multiple images (unless you have a very, very nice camera) at different exposures. After that, you take the pixels from each image that aren’t over or under exposed, and you generate a new set of pixels from them. That new set is your new image with color in all the right spots.

Lastly, I tried to make lemon chicken the other night. It went over pretty well, but I didn’t have any white wine. I think that would’ve added a lot to the flavor. There’s some good and cheap white wine sold down at the Mercadona, I just have to remember to pick it up before the next time I attempt to make the dish.

End of Third Week

I had a pretty good week this week. I’ve been mostly walking back from school to get some exercise in (it’s right at 4.0 miles) as well as to save trips on the metro. We also planned our trip to the UK. I’ll probably try to cover things in this post mostly in the same order as I have in the past couple of posts with classes first followed by things I visited and things I plan to go to still.

My classes were good this week, but I have to say that I didn’t quite enjoy them as much as last week. In Algorithms, Merrick covered mostly modular arithmetic and finished up some thoughts from last week. Although we covered modular arithmetic a lot in CS 1050, he found a lot of new material to present, in my opinion. The gist of modular arithmetic, to explain it briefly, is that sometimes you can take a long (often infinite) set of numbers and have them fit on a much shorter scale with repetition. So, for example if we wanted to do all the integers from 0 to 15 in mod 4 it would look like this:

Normal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Mod 4 : 0, 1, 2, 3, 0, 1, 2, 3, 0, 1,  2,  3,  0,  1,  2,  3

So, if you thought of time as a number line of all the hours since the start of time, that would be impractical. It’s a quarter to 1.22721379 × 1014 O’clock (About 100 trillion hours) just doesn’t compute. Instead, we work mod 12 such that hours go 1 through 12 repeatedly (or 0 to 23 in mod 24) because this makes more sense for us.

Note: Mod is similar to the remainder after division, but is distinctly not the same. If you divide 37 by 5, there’s a remainder of 2, and that is the same as 37 mod 5, but when you take negative numbers, it doesn’t work the same. -37 mod 5 is 3.

Anyway, there are some neat tricks that come about from this kind of math. An example would be (we did this one for homework) is the number 41536 – 94824 evenly divisible by 35? At first, that definitely seems like a daunting task, but if we work in mod 35, it’s easier. Assuming mod 35, we want 41536 – 94824 to be zero because if it is evenly divisible, then there won’t be a remainder after division (and anything that comes out to 0 after the mod is the same for positive and negatives). So, I’m going to hide the solution in a box both because it is long and mathy in case you don’t want to read it and to give anyone time to think if you want to try to see for yourself if it is evenly divisible.

Show »

The approach we took in class was first see if the number is divisible by 5, then see if it is divisible by 7. If it is divisible by both, then it is divisible by 35, otherwise it’s not. So, start by checking the first number for divisibility by 5.

4^1536 = (4^2)^768 We can take 4^2 and do mod 5 to get 1. So,  (4^2)^768 = 1 ^ 768 mod 5, and 1 raised to any power is 1. 1 mod 5 is still one. 9^4824 is the same as 4^4824 when you apply mod 5, and we can do the same thing as before to get 1^2412 which is just 1 again. So, mod 5, 41536 – 94824 is 0. Meaning it’s divisible by 5.

For 7, it’s similar, but different. It should be obvious that 41536 – 94824 is the same as (4^6)^256 – (2^6)^804. Now, using Fermat’s Little Theorem, we know that any number raised to the p-1 power then modded by p, which is prime is equal to 1. So, 4^6 mod 7 and 2^6 mod 7 are both 1. 1 – 1 = 0, and thus it’s divisible by 7. Divisible by 7 and 5 means divisible by 35.

Anyway, enough math for now. Kevin, Joe, and I went to Mount Tibidabo the other night to take some evening shots of the city.  Unfortunately, when we left, it looked like my camera was fully charged, but when we got there, it seems I misread it, so I wasn’t able to take many pictures. Kevin, however, was able to, so I think I’m going to ask him for those this week.

I’ve been eating in a lot more this week. Both Thomases (How do you pluralize Thomas?) and I have been walking the 4 miles back from school each afternoon in order to save trips on the metro. When we get back, we’ve spent a couple euro on bread to get baguettes, and then chorizo meat and edam or gouda if we’re out of meat or cheese. For dinners, I’ve found that vegetables and pasta are pretty cheap to buy daily, and I’ve been getting a kilogram of meat or so that lasts a bit. I haven’t found any ground beef, which I find surprising. All I’ve found is ground beef pork mix, which tastes pretty much the same, in my opinion. Overall, I’ve found eating in to be a mostly nice option. The biggest flaw is that I lack some basic cooking equipment that makes it a little more difficult. For example, an oven and measuring cups.

So, I found one and was shown another ice cream shop here recently. The first is over by the Picasso museum, which I need to visit. The flavors I’ve tried there were chocolate (which was amazing), Rochet (Which tasted just like the candies), and Café (which actually tasted a little like rum). They were by far better than most ice cream I’ve gotten in the US, especially the chocolate. A few days later, Anya showed me this place in Plaça del Rei where she said her family thought had some of the best ice cream (and by ice cream, I mean gelato). I had their chocolate, which was also amazing, and another flavor that I can’t recall, so I guess I’ll be foreced to go back there to find out. :-)

The city also goes crazy over soccer, or fútbol. The Barcelona team won, I believe, the European cup. Bacelona rioted after the game that night and apparently did 100.000€ (Where we use commas in numbers, they use decimals, and where we use decimals, they use commas. Go figure.) in damages. I started to go out to take pictures of the mayhem, but I was hearing explosions so loud that they hurt my hears with the window closed, I decided to stay in instead. It was certainly interesting to see from the room, but too dark and distant to get any real pictures.

Lastly, a few of us are planning to go to the UK. We bought tickets and we’re going to visit London, Liverpool, and Dublin. I’ll post details later in the week.