Tag Archives: pedagogy

Analyze, hack, create

One of these days I’ll get back to blogging about the mathematics courses I teach, which make up the vast majority of my work, but the MATLAB course continues to be the place where I am working the hardest, struggling the most, learning the biggest lessons about teaching, and finally having the greatest sense of reward. This week was particularly rewarding because I think I finally figured out a winning formula for teaching a large portion of this stuff.

This was the last in a three-week series on introduction to programming. We had worked with FOR loops already. I had planned to look at WHILE loops in the same week as FOR loops, then have the students play around with branching structures in week 2, then have them apply it to writing programs to do numerical integration week 3 for use in their Calculus II class in which most of the class is currently enrolled. But the FOR loop stuff went very roughly. So I moved the numerical integration stuff up a week and saved the entire remainder of looping and branching structures — WHILE loops, the IF-ELSEIF-ELSE structure, and SWITCH — for week 3.

I approached it like this.

The majority of their homework consisted of watching three videos: one on general programming in MATLAB, another on MATLAB loop structures in general, and a third on IF and SWITCH statements. That’s about 20 minutes of straight viewing; I told the students to budget an hour for these, since they’ll want to pause and rewind and work alongside the videos. Then, the majority of their homework was this M-file:

%% Script M-file for April 5 Prep/HW for CMP 150.
%
% For each block of code below, write a clear, English paragraph that
% explains what the code does. You can play with each block of code by
% removing the comment symbols and running this file. (You can "uncomment"
% lines by deleting the percent symbol or by highlighting the code you want
% and selecting Text > Uncomment from the menu above.)

%% Code example 1

 x = input('Please enter in a number less than 100: ');
 while x < 100
     disp(x)
     x = 2*x - 1;
 end

%% Code example 2

 x = input('Please enter in a number: ');
 if x>=0
     y = sqrt(x)
 else
     y = exp(x) - 1
 end

%% Code example 3

 value = input('Please enter in a whole number between 1 and 20: ');
 switch value
     case {2, 3, 5, 7, 11, 13, 17, 19}
        disp('Your input is a prime number.')
     case {1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20}
         disp('Your input is a composite number.')
     otherwise
         disp('I do not think you entered in a whole number between 1 and 20.')
 end

In other words: Here’s a bunch of code. Write up a plain-English description of what everything is doing. That was their homework. (Here’s the full assignment.)

Then in class, we played a game. For each code sample, I asked, “What if I entered [fill in the blank] to this bit of code?” For example, for code sample #1, what would happen if I entered in 100? One student immediately said, “Nothing”. Another said “It would give you a ‘0’ because that’s what ‘100 < 100’ returns as in MATLAB.” Then I had them close their eyes. “How many say, ‘Nothing’?” Count the hands that go up. “How many say ‘0’?” Count those hands. Put the tally on the board. The result: 7 for “nothing”, 6 for “zero”. Instant discussion fodder.

(By the way, this would have been a perfect place for clickers. I’m working on that.)

Next I asked, “What would happen in code sample 1 if I put in a negative number?” One guy said: “I know! I did that, and the thing kept running and never stopped, and I had to unplug my computer!” So I showed them all Control-C; then asked, “Why did that [the failure of the program to stop] happen?” In no time at all — a high-order discussion about an important related topic to looping structures (avoiding infinite loops) that I had not even planned to bring up.

We played that game for 20 more minutes. Students were into it. They were coming up with their own cases. We tried entering in ‘Hi mom’ to code sample #1 and it actually gave something back. It was mysterious and entertaining and nerdy. They discovered that testing out extreme cases is not only important for understanding your code, it’s fun. And it was a lot better than lecturing.

The best thing is, when I got them finally into their lab problems, they were asking better questions. “I think I can do this program with a SWITCH statement, but could I make it better with an IF statement?” And: “I’ve got all the cases listed out here in my SWITCH statement, but I wonder if I could just use a vector or LINSPACE to list them out instead.

So that’s going to be my approach from here on:

  1. Analyze: Look at someone else’s code and write out a complete, plain-English description of what every part of it is doing.
  2. Hack: Take the same code and modify it, tweak it, rewrite it, throw extreme cases at it. This is the bridge between reading code and writing code.
  3. Create: Write some code to do something new — now that you’ve learned the language from someone else’s use of it.

For all I know I could be totally reinventing 40-50 years of established best practices in computer science pedagogy. But it’s pretty exciting nonetheless.

2 Comments

Filed under Education, MATLAB, Problem Solving, Teaching, Technology

Piecewise-linear calculus, part 3: Integration

This is probably the last of three articles on how piecewise-linear functions could be used as a helpful on-ramp to the big ideas in calculus. In the first article, we saw how it’s possible to develop some of the main conceptual ideas of the derivative, without much of the technical notation or jargon, by using piecewise-linear functions. In the second article, we saw how to use the piecewise-linear approach to develop an alternative limit-based definition of the derivative of a function at a point. To wrap things up, in this article I’ll discuss how this same sort of approach can help in students’ first contact with integration, again by way of a hypothetical classroom exercise.

When we took this approach with derivatives, we used the travels of three college students from their dorm rooms to the cafeteria. Each student had a different graph showing his position as a (piecewise-linear) function of time. From these we could get instantaneous velocities. Now let’s consider the reverse situation. A fourth student, Dominic, is traveling from his dorm room across campus, and we have this graph that shows his velocity (in meters per second) as a function of time (in seconds):

Question: How far did Dominic travel in the two-minute span shown here? This is easy, of course, and students get this right away: He traveled at 1.5 meters per second for 120 seconds, so that’s 120 x 1.5 = 180 meters. Distance equals rate times time.

Well, it turns out Dominic has a roommate, named Eric. Eric is leaving his dorm room for a walk too, and his velocity graph looks like this:

Same question: How far did Eric travel in two minutes? There’s a small amount of thinking to be done this time, but it’s still easy: He went 0.5 meters per second for 60 seconds, which is 30 meters; and then 1.5 m/s for 60 more seconds, which is 90 meters. Grand total: 120 meters.

A simple but very important question can be posed here: How come we couldn’t just use distance = rate x time to calculate Eric’s distance travelled? The answer is simply that Eric was not going the same velocity all the time. He had a “piecewise-constant” velocity, so we can use d = rt on either of the two time blocks we want to calculate distance; but we can’t use it globally because his speed changes. In other words: A nonconstant speed requires a kind of “local” d = rt calculation but we cannot use d = rt globally because the r isn’t a single number all the way through.

Now consider Frank, who is following both Dominic and Eric around but whose velocity graph is:

I’ve added the dashed vertical lines just to show where the graph breaks. How far did Frank go in two minutes? Still easy, but this time more work: Total distance = (0.5)(30) + (1.0)(30) + (1.5)(30) + (1.0)(30) = 120 meters.Related question: What does this calculation compute in terms of Frank’s velocity graph? With the dashed lines added in, students pretty quickly see that the sum they did is just an area sum, which we are using because we are doing four local d = rt calculations.

At this point students can stop and think about a few things they are learning:

  • Calculating the distance traveled by a moving object cannot be done by calculating d = rt if the velocity changes.
  • Instead, we have to “localize” the d = rt calculation by breaking up the time interval into chunks on which the r is constant. Do this on each chunk and then add up the resulting distances to get the total distance.
  • This “chunk-wise” calculation is really just finding the areas of a bunch of rectangles.
  • “Chunk-Wise” would be a very good name for a rock band. But we digress.
  • This is really exactly the opposite sort of thing we did for derivatives. With derivatives, we were given a position function that was piecewise-“straight” and found velocity. Here we are given velocity graphs that are piecwwise-“straight” (actually constant) and finding positions (actually displacements).

Now comes the twist in the problem. We realized, when studying derivatives, that human beings cannot change velocity in an instant. So in the case of Eric above, he cannot possibly go from 0.5 meters per second to 1.5 meters per second without some kind of acceleration in between. His velocity graph is more likely to look like this:

Question: How far did Eric travel now?

Just like when the twist in the problem came for derivatives, I like just to throw this question out there to students and see what they come up with. Most will get the distance travelled on the 0-30 second and 90-120 second interval correct because those are the places where d = rt is in effect. But the 30-90 second interval in the middle doesn’t have constant velocity, so we can’t do that here. I find students do one of three things:

  1. Transfer the idea that distance traveled = area under the velocity graph, then use geometry to calculate the area from t = 30 to t = 90.
  2. Split the middle interval up into subintervals (usually two of them) and do some kind of rectangle approximation.
  3. Average the heights of the endpoints of the middle line segment — that would be a height of 1 m/s — and do a d = rt calculation based on that average.

Each of these three approaches contains a lot of right ideas. The first and third will give them the exact results, and the second one might if they pick the approximations wisely. But any way they go at it, they acquire the right ideas: (1) Distance travelled = area under the velocity graph, and (2) when the velocity graph is not constant, we either approximate or use geometry to find the distance. Note also that if they get this far, they can do any displacement problem like it as long as the graph is piecewise-linear, because they have geometry on their side. For fun, throw in a graph where one of the pieces is below the t-axis and see what they do with it. It goes back to the idea from derivatives that the sign of velocity indicates direction — an idea they will carry with them if their intuition is sufficiently built up at first.

From here it’s an easy jump to start students thinking about non-piecewise linear velocity graphs. Give them one, and ask them to find the distance traveled. The natural thing to do based on their previous work is to try and approximate with piecewise-linear or piecewise-constant graphs. The latter approach is what we call a Riemann sum, and it’s very intuitive to students that more piecewise-constant “chunks” gives better results.

Some ways I think this approach is an improvement on the way calculus textbooks usually do integration:

  • The usual approach starts students off with “the area problem” — find the area under the graph of a function, above the x-axis, and between x = a and x = b. There is no real reason given to the students to care about this problem, and the all-important connection between areas and displacement is relegated to the tail end of the section. Instead, here we are developing the notion of area as a necessary tool for calculating distances traveled by objects whose velocity isn’t constant.
  • Because the usual approach buries the connection between areas and displacement, by implication it also buries the connection between derivatives and antiderivatives. By contrast, here we are making the connection between velocity and position via areas the focal point of the problem. There will be no surprises once we get to the Fundamental Theorem of Calculus.
  • The usual approach presents Riemann sums as the solution to the area by fiat. It’s just “the way we do it”. Here, we build the idea of Riemann sums as a refinement of an intuitive idea, namely that of breaking up the non-constant parts of the velocity graph into constant chunks. Riemann sums are something that the students would have come up with themselves if they’d just been given the chance and the motivation to do so.

As always, I’m interested in your thoughts and criticisms of these three posts. Leave those in the comments.

Reblog this post [with Zemanta]

Comments Off on Piecewise-linear calculus, part 3: Integration

Filed under Calculus, Math, Teaching

What are “essential teaching skills”?

In my last post, I expressed incredulity at Pat Rogan’s statement that by limiting education degrees to no more than 30 hours of pedagogy courses, the state of Indiana would be “put[ting] educators without essential teaching skills into classrooms”. I brought up the example of one-room schoolhouse teachers and homeschooling parents as examples of people who teach successfully without anywhere near that amount of coursework. Another example I realized this morning was my own profession of college teaching. Most college professors have never had a pedagogy course in their lives, and yet many of those are among the best classroom educators our society has to offer. They certainly have “essential teaching skills”.

Of course there are also many professors whose teaching is atrocious. But there are also high school teachers with 30+ hours of pedagogy courses whose teaching is equally atrocious, and it’s highly questionable whether they have “essential teaching skills” despite surviving all that coursework.

What exactly are “essential teaching skills”? How do these differ from one teaching situation to the next — the preschool classroom, elementary schools, public high schools, private high schools, college classrooms, homeschoolers’ living rooms? Is there a single set of “essential teaching skills” that is common to all teachers, regardless of their context? And what role does education coursework play in conveying those skills?

19 Comments

Filed under Teaching