Monthly Archives: October 2012


Math 32A Midterm 1 Review

I wrote up a couple of review questions for the first midterm for Math 32A this quarter. The questions without solutions are available here, and full solutions here. There are two multipart questions, which cover the majority of the material we’ve covered in the course so far.


Reusing Empty Bottles

When I started home brewing, I naively thought that brewing my own beer would end up costing less than buying beer. It is true that the cost of ingredients for a batch of beer cost less than buying an equivalent number of (fancy) six-packs, but there are other costs associated with brewing. One cost that I didn’t anticipate is the price of empty bottles. At around 75 cents apiece at my local brewing supply shop, the bottles cost as much as the beer I put in them! Using these bottles pushes the cost of a home brew six-pack towards $10, ignoring the startup cost of equipment.

Needless to say, reusing bottles has become a financial necessity. The rinse-scrub-rinse-sanitize cycle is tiresome, but there really isn’t any alternative. After all, brewing beer is 90% about cleaning and only 10% about actually making beer.

Considering the ridiculous cost of empty bottles,  it makes the most sense to just use empty commercial beer bottles. In some cases, full bottles of beer cost less than empty ones — you just need to be sure that the bottles you’re using don’t have screw off caps as these bottles won’t seal properly. The only problem that I ran into with using commercial beer bottles was the labels. I don’t know what glue they use to affix the labels, but they are a pain to get off. I tried soaking and scrubbing and various solvents and detergents. By far the best and easiest option for label removal turned out to be OxiClean. They make a version that is free of perfumes and dyes, and it works perfectly. After soaking the empty bottles in a solution of OxiClean for a few hours, the labels practically fall off.

Using empty commercial bottles for brewing is, I think, the best way to go so long as you’re on top of keeping them clean. Here’s what I do to ensure that my beer goes uncontaminated:

  1. Rinse bottles thoroughly immediately after finishing. I fill them half way with water, shake vigorously, drain and repeat at least 3 times for most beer. If the beer is bottle conditioned, there tends to be some yeast stuck to the bottom of the bottle, in which case the bottles need to be scrubbed at this point with a bottle brush. For bottles that are force-carbonated this step doesn’t seem necessary.
  2. Let the bottles soak in a bucket of OxiClean solution for a few hours. Remove the labels of the beer and scrub the insides of the bottles thoroughly. Rinse each bottle at least 3 times, shaking vigorously.
  3. Let the bottles dry upside down. Once they are completely dry, store them until bottling day. I usually store them upside down so that dust doesn’t settle inside them.
  4. On bottling day, rinse the bottles and let them soak in sanitizing solution until immediately before filling. Empty the bottles and let them drain upside down on a sanitized rack for a few minutes before filling the bottles.

There you have it. Inevitably, some bottles from every batch are given away never to be seen again, but reusing commercial beer bottles can easily  make up the difference.

computer science expository math

Estimating the Second Frequency Moment

I just uploaded an updated version of an essay, Estimating the Second Frequency Moment. The frequency moment problem was addressed in the seminal paper of Alon, Matias and Szegedy. In my essay, I give a couple of results from that paper and give indications of how the results can be generalized.

Suppose you are shown a stream of numbers \(s_1, s_2, \ldots, s_n\) where each \(s_j \in \{1,2, \ldots, m\}\) for \(j = 1, 2, \ldots, n\). If \(f_i\) denotes the number of times \(i \in \{1, 2, \ldots, m\}\) (that is the frequency of \(i\) in the stream), then  we define

$$F_2 = \sum_{i = 1}^m f_i^2 .$$

To compute \(F_2\) naively, we can maintain counters for \(f_1, f_2, \ldots, f_m\), but this approach requires a lot of memory as \(m\) may be large. Instead, we can estimate \(F_2\) by defining a random variable that can be computed from the stream whose expected value is \(F_2\). By maintaining several independent versions of this random variable, we can obtain a good approximation of \(F_2\) using an amount of memory that is only logarithmic in \(m\) and \(n\).


India Red Ale

Yesterday I started brewing my first all-grain batch of beer. Inspired by my recent interest in hoppy red ales (Saint Rogue Red, Hop Head Red and Free Range Red to name a few favorites) I decided on a recipe from Randy Mosher’s Radical Brewing which he calls an “India Red Ale.” I tend to like the hoppy red ales because they have the aggressive hop character of an IPA but the bitterness is tempered by the sweetness of darker malts. The recipe is as follows for a 5.5 gallon batch:

Grain Bill

  • 6.5 lb pale ale malt (American 2 row)
  • 5 lb Munich malt (dark, 8 – 10 L)
  • 0.75 lb crystal 40
  • 0.5 lb crystal 80
  • 1 oz black patent


  • 2 oz Cascade (60 min)
  • 2 oz Cascade (30 min)
  • 2 oz Goldings (5 min)


  • American Ale (Wyeast 1056)

I performed a single infusion mash for 60 minutes at 153 F at a water to grist ratio of 1.25 qt/lb. After a single batch sparge, I obtained a little over 6 gal of wort at a gravity of 1.044. This corresponds to a brewhouse efficiency of about 60%, which was a bit less than I hoped, but is about what I expected for my first all-grain batch. After the boil, I ended up with almost 5 gal of wort at an original gravity of 1.054.

A few hours after pitching the yeast, my fermentor airlock was happily bubbling away; so far so good. I’m hoping for a final gravity of 1.014, 5.3% ABV and about 70 IBU…

Update 1 In light of an imminent heat wave, I’ve had to take measures for keeping the fermenting wort cool (under 70 F). I placed the fermenter in a shallow bucket of water and draped towels over the whole thing. Hopefully some evaporative cooling will do the trick while the temperature in my apartment gets into the upper 70’s.

Update 2 After 18 days of fermenting in the primary at around 70 F, the beer was ready to bottle. I measured a final gravity of 1.010 for an ABV of about 6%. I primed the beer for bottling with 3.5 oz of corn sugar for moderate fizziness.

It’s been three weeks since the bottling, so I’ve tasted a few glasses of the beer. I have to say that I am very pleased with the results: a nice rich malty back with a healthy smack of hops. I’ll give full tasting notes in a future post.


32AH HW2 #2

My hope is that this picture will help with question 2 on the second homework:

The picture indicates the situation in $\mathbf{R}^3$, but the idea generalizes to $\mathbf{R}^n$ for any $n$. The idea is that the set $W$ is the $(n-1)$-dimensional hyperplane containing $x_0$ that is perpendicular to the vector $u$. The point $w_0$ is the point in $W$ closest to $x \in \mathbf{R}^n$.

Intuitively, we should expect that $w_0$ is the intersection of $W$ with the line containing $x$ perpendicular to $W$ (i.e. parallel to $u$). Your job is to formalize this intuition in terms of the vector geometry we’ve learned. As the hint in the problem suggests, a good strategy is to apply the Pythagorean theorem to the triangle $x\ w_0\ w$. Notice that in order to apply the Pythagorean theorem you must prove that the vectors $x – w_0$ and $w – w_0$ are orthogonal. Once you define $w_0$ (in terms of $x$, $x_0$ and $u$) you will also need to prove that $w_0 \in W$.