I have left Harvard as of July 1, 2008 to take a position at NYU. This website has been cached and left static. Feel free to browse my new website, aka "What the heck is a Clinical Associate Professor?"

04.08.08

Google Summer Of Code LaTeX Project

Posted in LaTeX, Web at 8:48 am by leingang

The TeX Users Group will be participating as a mentoring organization in the Google Summer of Code program, and my project of a Dublin Core metadata interface was accepted.  I’m hoping some enterprising youth with lots of experience in programming TeX will be interested in the project.

Here is an overview of the project: Dublin Core is a scheme for expressing metadata (data about data) in a reliable, machine-readable way.  It can be expressed in various languages, including RDF, which can itself be serialized in XML.  Adobe’s eXtensible Metadata Platform allows RDF+XML statements to be embedded into PDF files.  This metadata can then be read by search engines in order to give context to the document besides its simple contents. 

TeX and LaTeX can be used to produce PDF documents, and have rich macro-programming environments.  One goal of the project is to add simple commands which can write the complex metadata statements into the PDF without the user needing to know anything about RDF, XML, or Dublin Core itself.  Another goal would be for more advanced users to augment this interface with new Dublin Core element sets and vocabularies.

I’ve always taken an interest in the semantic web, and apparently there aren’t too many people in this group also interested in TeX.  So if the project flies I think it could be very useful.

Blogged with the Flock Browser


Tags: , ,

03.20.08

Number pages within chapters in LaTeX

Posted in LaTeX at 9:17 am by leingang

In latex, the \numberwithin command allows one to bind one counter with another. A common example is the section counter and the chapter counter. When a new chapter is created, the chapter counter increments, and the section counter is reset. In this scheme, if the last section of chapter 1 is labeled “1.5″, the first section of chapter 2 is labeled “2.1″.

In the process of preparing a large handout, put together in stages and repeatedly distributed, a student asked if I could number the pages of a document within the chapters. So each page would be labeled chapter-page, and the first page of each chapter would be page 1.

Sounded simple enough: just use

\renewcommand{\thepage}{\arabic{chapter}-\arabic{page}}

(this changes the way pages are labeled) and

\numberwithin{page}{chapter}

to change the numbering. But this doesn’t quite do it, because \numberwithin resets the counter to zero, and so the first page of chapter 4 gets labeled as “4-0″. I need to start a new chapter, then reset the page counter to one, not zero.

There is probably a package which does this, but five minutes of googling didn’t produce it. So I started to roll my own. One can write a \Chapter command that calls \chapter then resets the page counter. The disadvantage here is that (1) you have to search-and-replace existing code, and (2) \chapter is a pretty complicated command with a starred version and an optional argument. The \chapter macro calls lower-level macros and actually returns a seven-argument macro with four arguments filled in. So rather than call the \chapter macro, I want to make adjustments, then return \chapter so that it can parse as normal. That’s when I tried:

\let\oldchapter=\chapter
\def\chapter{\resetcounter{page}{0}\oldchapter}

This adds the page reset to the beginning of the chapter, without changing the way it’s used. The trouble is that \chapter clears the page before starting the new chapter, and that page needs a label. So this made sure the first page of Chapter 4 was labeled 4-1, but now the last page of Chapter 3 got labeled 3-0!

What I needed was to return \chapter, but make sure LaTeX executed the \resetcounter command right afterwards. The solution is \expandafter, which defers token expansion by one position. From The TeXBook:

TeX first reads the token that comes immediately after \expandafter, without expanding it; let’s call this token t. Then TeX reads the token that comes after t (and possibly more tokens, if that token has an argument), replacing it by its expansion. Finally TeX puts t back in front of that expansion.

And here’s the implementation:


\let\oldchapter=\chapter
\def\resetpage{\setcounter{page}{1}}
\def\chapter{\expandafter\resetpage\oldchapter}

The parsing works like this: upon reading the new \chapter macro, TeX encounters \expandafter, reads \resetpage but holds onto it. It then expands \chapter, which under the hood returns that seven-argument monster macro. At that point \resetpage is called.

Update 2008-04-08: Peter tells me the package I’m looking for is chappg.  Should have googled more!

Blogged with the Flock Browser

Tags: , ,

02.29.08

This Psychologist Might Outsmart the Math Brains Competing for the Netflix Prize

Posted in Math, News at 1:29 pm by leingang

This month’s Wired contains an article about the Netflix prize, offering $1,000,000 to the person or team that can improve Netflix’s recommendation engine by 10%.  It’s an interesting tale of the frontier of data-centric personal services.  The “hero” of the article uses not only mathematical algorithms but psychological concepts when gleaning information about past preferences in order to predict future ones. 

For instance, there’s the concept of “inertia,” or another way, relativity, when ranking movies on a simple 1-5 scale.  Somebody might give the same movie two different rankings depending on the most recent movie he or she watched.  If you see, for instance, Gattaca followed by The Matrix, you might give  The Matrix a 4 because you think it’s so much better than Gattaca.  But if the previous movie was a 5 (I’ll let you fill in your favorite here), well, maybe The Matrix earns only a 3.  Mathematically, we would say that the relationship between the set of movies and a person’s ratings for them may not actually define a function as the purely math models assume.

The other cool thing about this article is that it’s written by mathematician Jordan Ellenberg, with whom I went to grad school back in the day (the nineties). 

Blogged with Flock


Tags: , , , ,

02.18.08

The freshman experience

Posted in News, Education at 2:29 pm by leingang

Today I saw in one of the University of Michigan student papers an article about a WSJ blog post about a Chronicle of Higher Education column about a new book about college freshmen and their first experiences away from home. The Chronicle story is called “The Myth of First-Year Enlightenment” and the book tries to burst the bubble of those who picture a monumental eye-opening and metamorphosis during the first year. Instead of undergoing then sudden realization that the world is much bigger than they originally thought and what they had come to value was now clearly so…philistine (this was the word used at my freshman orientation), Tim Clydesdale writes,

Most of the mainstream American teens I spoke with neither liberated themselves intellectually nor broadened themselves socially during their first year out…What teens actually focus on during the first year out is this: daily life management.

Most American teens keep core identities in an ‘identity lockbox’ during their first year out and actively resist efforts to examine their self-understandings through classes or to engage their humanity through institutional efforts such as public lectures, the arts, or social activism. Contemporary teens are practical men and women. They . . . manage their daily lives fairly well. But they are not, by and large, thinking men and women.

Practical rather than paradigmatic shifts, I suppose. Clydesdale writes that some students do undergo big philosophical changes, but those are the exception. They end up becoming college teachers and perpetuate the metamorphosis myth.

How does that affect current college teachers? I think the older I get the more I appreciate the college experience, but I have to remember what I was actually like as a college freshmen. And even then I have to acknowledge that my experiences of learning the discipline I teach aren’t shared by the general population of students taking introductory courses in that discipline. Although Math 160’s at the University of Chicago changed the way I think about mathematics, that doesn’t mean that everyone should take it. But understanding where students do come from helps me reach them.

Getting this away from me: James Lang writes in the Chronicle story that we can do better at motivating our courses with what our students are seeking. No, not grades. :-) But practical-minded students need the tools to communicate, to analyze, to formulate, to critique, to defend, to think, to solve problems, and so on. He says he’s stopped advertising that he plans to change the way students think, leaving it as a covert mission. Now he focuses on teaching them to think in the first place.

Blogged with Flock

Tags: ,

02.16.08

In defense of fractions

Posted in Math, News at 7:14 pm by leingang

A couple of people pointed out this article in USA Today about a mathematics professor who thinks fractions need not be taught in schools. 

I know that I work for one of the most famous organizations in the world, and I’m well aware that the things I write on my blog could be misconstrued as coming from my employer or representing positions held by them.  So I keep things pretty close to the vest.  But I hope I’m not being too controversial when I say that I like fractions and hope they continue to be taught.  I’m not quite sure how algebra can be done without fractions (what becomes of rational functions if you can’t abstractly divide polynomials?), and without the skills to algebraically manipulate expressions, calculus becomes very hard to do as well. 

Prof. DeTurck compares fractions to roman numerals, which of course were abandoned once the arabic system became more widespread.  The arabic system had place value, that is, the idea that the position of a digit within a number changed the value of the number.  They also had one of the most important numbers: zero.  With these ideas, finitely many symbols can be used to express infinitely many numbers.

The quickest to move to the arabic system from roman numerals were the accountants, and indeed, a big advantage of arabic numerals is the ease of computation.  The same could be said of decimals versus factions: it’s usually easier to add decimals.  Alexander Hamilton wanted a base ten system for the currency of the United States, rejecting the 12 schillings per pound, 20 pence per schilling system long before the UK themselves did.  Computers are built for floating-point arithmetic rather than adding fractions, and so most stock exchanges list decimal prices for commodities now. 

But fractions are for more than just arithmetic. And decimals are only useful ways to express numbers when the numbers themselves are expressed as points on a line.  But there are other ways that numbers are used.  If I show you a pie and offer you 0.25 of it, how would you cut the pie?  If you said “I’d cut it in half, then cut one of the halves in half”, then you converted the 0.25 to 1/4 and used the fact that (1/2)(1/2) = 1/4.  But if numbers are only lengths, I think the only way to do this is to cut a circular piece out of the center of the pie whose radius is 0.5 of the radius of the whole pie.

And don’t forget that many fractions aren’t expressible exactly in decimals.  To get a sixth of the pie (a much more modest slice), you’d have to cut out a circle whose radius is the square root of 0.166666… which is about 0.408248. 

So I say, vive les fractions.  And mmm…pie….

Blogged with Flock


Tags: ,

February 16 roundup of Math 21a

Posted in Math 21a, Spring 2008 at 6:15 pm by leingang

We’re now firmly grounded in three-dimensional space. We talked this week about the various linear objects in 3D: lines, points, planes, and finding equations for them. Also, we showed how to define and calculate the distance between points and lines, lines and planes, etc.

Then we moved into the functional unit of the course. A function of two variables has as its graph a surface in three-dimensional space. Graphing these is a challenge of the brain but of the hands. But there are some tips, such as the method of traces.

Finally, we have other ways to measure space besides our boring old rectangular cartesian coordinates. We defined polar coordinates in the plane, and cylindrical and spherical coordinates in space, to better express certain surfaces. For instance, the cone in three-space can be described as z=\sqrt{x^2+y^2} in cartesian coordinates, but in cylindrical all you need to say is z=r.

Tags: , , , ,

February 16 Roundup of Math 1a

Posted in Math 1a, Spring 2008 at 6:08 pm by leingang

In the past week we’ve defined the derivative as the limit of a difference quotient.  Graphically, it’s the slope of the line tangent to a curve at a point.  But it has quite a few interpretations in various models.  If the function is position, the derivative is velocity.  If the function is cost, the derivative is marginal cost.  If the function is mass, the derivative is density.  The number of different uses for the derivative are what make it so important to study.

We looked at various interplays between a function and its derivative.  For instance, when a function is increasing on an interval, the derivative is nonnegative (positive or zero) on that interval.  If the function is decreasing, the derivative is negative or zero.  And if the graph has a horizontal tangent line, the derivative is zero.  It turns out–and we will be showing this when we get to The Most Important Theorem in Calculus–that the converses of these statements are pretty much true as well.  That is, if a function has a positive derivative on an interval, it’s increasing on that interval, and so on.

The derivative can’t tell you everything, however.  For one, it can’t tell you the function value at a specific point without any other information.  This is true even of constant functions, which all have the derivative zero, no matter what the constant is.  It also can’t tell you about the concavity of the graph of a function.  But that can be computed from the second derivative.

Although we define the derivative in terms of a limit, eventually we will develop a set of rules to make calculating derivatives easier.  That’s the subject of Chapter 3.  However, it’s important not to lose the foundational ideas behind what the derivative actually is and what is for.

Slides for this week are posted.

Tags: , , , ,

02.07.08

Math 21a roundup for February 6

Posted in Math 21a, Spring 2008 at 2:31 pm by leingang

A vector is a “thing” which has magnitude and direction.  We sort of leave those two things undefined, too, but this is better than nothing.  If you take an abstract algebra course, you’ll learn that a vector is any element of a vector space, but that probably doesn’t help here, either:-). 

Either thinking geometrically (drawing arrows) or algebraically (recording a vector’s components), the important thing is that we can add, subtract, and scale vectors.  Also, these operations are similar to those we know for regular numbers–which we’re going to call scalars from now on for no particularly good reason.  For instance, adding two vectors is a commutative operation: the order of addition doesn’t matter.  Scaling distributes over addition, and so on.  (This is the “abstract” definition of vector space: a set of things you can add and scale).

Can you multiply vectors?  Not in the same sense that you can multiply real numbers.  You can multiply two-dimensional vectors by pretending they’re complex numbers.  This doesn’t work in spaceland, however.  There are two useful products of vectors, though: the scalar (or dot) product and the vector (or cross) product.  The dot product measures the compatibility of vectors in some sense.  If the dot product is positive, the angle between the vectors is acute.  If it’s negative, the angle is obtuse.  And if it’s zero, the vectors are perpendicular (another new word for a known concept: we’ll say orthogonal now instead of perpendicular). 

The cross product is coming up on Friday.

Blogged with Flock


Tags: , , ,

Math 1a roundup for February 6

Posted in Math 1a, Spring 2008 at 2:14 pm by leingang

Continuity is the property that the limit of a function near a point is the value of the function near that point. It’s one of many “nice” properties a function can have. Functions can fail to be continuous in a number of different ways, including jumping from one value to another, having a simple “removable” discontinuity, or blowing up to infinity near a point.

Lots of times we want to model a situation with a function, and we assume the function is continuous to make our lives easier. For instance, the population of a bacteria culture in a dish. Clearly there are only whole numbers of organisms in the culture, but we pretend the population function of time is continuous because relative to the population size, an error of one by rounding isn’t that much.

An important consequence of continuity is the intermediate value theorem, which says that a continuous function on an interval assumes all the values in between the values at the endpoints. This theorem has important consequences, for instance:

  • the square root of two exists
  • at some point in your life your height in inches equaled your weight in pounds
  • A table on an uneven floor can always be turned so that it won’t wobble
  • Right now there are points on opposite sides of the world with the same temperature!

Blogged with Flock

Tags: , , , ,

02.05.08

Math 21a roundup for February 4

Posted in Math 21a, Spring 2008 at 3:39 pm by leingang

First, we played a rousing game of Name Bingo to break the ice. Then we got down to business.

One major goal of Math 21a is to take what we know in the line and on the plane and generalize it to three-dimensional space.

One thing is immediately confusing: we have three axes in space, and we only allow those which are “right-handed” (biased, perhaps, but we have to pick one).

But the distance formula generalizes to three dimensions rather well: the distance between two points is the square root of the sum of the squares of the differences between the original coordinates, or

|(x_1,y_1,z_1)(x_2,y_2,z_2)| = \sqrt{(x_1-x_2)^2 + (y_1-y_2)^2 + (z_1 - z_2)^2}

Blogged with Flock

Tags: , , , ,

« Previous entries ·