At the moment, my honors studnets have spent about two hours working with vpython. As a group, they find it pretty cool, but most aren’t quite sure why we’re studying this in physics, and they can easily get frustrated with all the little syntax problems that can keep their programs from running.

My goal for this lesson was to begin to break through some of this and help my students to see why computer modeling is so important for physics, and how it will become a powerful tool that will greatly expand the range of problems they can take on.

We started with me showing this question to my students

A student is running at his top speed of 6 m/s to catch a school bus, when she is just 10 meters away, the bus leaves the bus stop, accelerating at $1\frac{\textrm{m}}{\textrm{s}^2}$ Does she catch the bus?

I asked the students to think about this question and pull out a scrap of paper to rate their understanding of the question the following 1-4 scale:

1. I wouldn’t even know where to get started on this problem
2. I think I could write something down for this problem, but I’d have a lot of questions.
3. I think I could solve this problem, but I might have one or two questions.
4. I own this problem. It should run away from me if we meet in a dark alley.

I then asked each table to collect the slips of paper anonymously and report a table average. All of them were between 3-4. Nice—we’ve mastered CAPM and CVPM, and we know it.

I then showed my students this program, buschase.py:

I only showed it for a second, since I didn’t want them looking deeply at the program just yet.

then we ran it, and watched this on the screen:

I asked them what it thought, and at first they said it looked pretty long. Since they are mostly total neophytes at programming, I had to tell them that something like Microsoft Word checks in at millions of lines of code, they suddenly saw this as pretty short, at only about 40 lines of code.

Since they had each already written a constant velocity program, I asked them how many lines that was—25 lines, and we talked about how it was pretty impressive that you could add all this stuff, a second, accelerating object, an arrow to mark when the person catches the bus, etc, with only a dozen additional lines. And I asked if I wanted to change the acceleration of the bus to $2\frac{\textrm{m}}{{s^2}}$, how many changes would this require? Everyone quickly jumped on the big idea—1 character.

From there, I brought up this statement and asked the studnets what it meant.
bus.pos = bus.pos + vbus*deltat

Students easily recognized it as pretty similar to one of the CVPM equations we’d seen before, $x_f=x_i+vt$

“So is this an eqaution, I asked?” And what would it look like if we tried to translate it into mathematical notation.

Students had little problem seeing that it would look something like

$x=x+vt$
And then soon after, they saw that something is pretty fishy with this “equation” since the only way for this to be true is for $v$, $t$, or both to be zero, and that doesn’t agree with the physics of the situation.

This lead into a wonderful discussion of the meaning of the = sign in math, physics and computer science.

I wrote $a=\frac{\Delta v}{\Delta t}$ on the board and asked where this came from. Did someone find it carved on a stone in the forest? Did they have to prove it from some more fundamental principle? This took a lot of thinking (they’d never really questioned deeply where the formulas come from), but soon students saw that it was a definition, just a name some old guy gave to the slope in a velocity graph. Cool.

So what about this equation: $a^2+b^2=c^2$. Pythagorean theorem, they saw quickly. Right triangles! How do you get this? Soon they saw that by thinking about ideal right triangles, and reasoning with mathematics, you can prove this statement works for the sides of a right triangle, which is totally different from making a definition.

Finally, what about our favorite: $a=\frac{F_{net}}{m}$. Where do you get this—definition? Proof? Neither. You can’t sit around with abstract “objects” in your head and reason about how they should move. You need data, and when you take the data (as we did in class) you find that the rate at which the velocity of the object changes, turns out to be directly proportional to the net force, and inversely proportional to the mass. Empirical law

Who knew a tiny little = sign had so many meanings?

bus.pos = bus.pos + vbus*deltat

Students saw that really what we are trying to say here is that the new position of the bus is the old position of the bus multiplied by the change in time.

And so we have a 4th meaning of the equal sign, assignment, or “gets.”

I then asked the students to think how many lines they woudl need to add to a CVPM (constant velocity) program to get a CAPM. We used logarithmic thinking—1, 10 or a 100, which is closest? Everyone said 1, and then someone said, wouldn’t you just write

vbus = vbus + a*deltat

Wowzers. What if you only knew the force?

vbus = vbus + Fnet/m*deltat

Can you feel your superpowers pulsing? It’s like shooting lightning from your hands! One line of code, and suddenly this boring CVPM cart comes alive with acceleration.

And so I then asked the students to rate their ability to solve the bus chase problem using vypthon on the same 1-4 scale. This time the averages were lower (obviously—they’ve been programming less than 3 hours), but still in the 2-3 range. Wow!

Then I had us look back at the velocity graph for the rocket problem from the final exam:

How hard would it be to write a program to model the motion of this rocket? How many changes do you see? Everyone quickly caught on that you’d just need to change the acceleration twice—once when the rocket turns off, and again when it hits the ground.

What if you wanted to add drag? The students guessed that that would just be an additional line or two. But then I told them that the amazing thing is that vpython can model the rocket perfectly with drag, and tell you, to the second when it will hit the ground. Trying to do this by hand, to get some formula you can then plug numbers into to get an answer, using all the math humankind has discovered, turns out to be impossible. It’s like shooting lightning bolts from your fingertips!

It was at this point that I asked the students to take out a piece of paper and write what they were learning—the 20 minute pulse check.

From there, we went to the computer lab to start working on our 3rd vpython programming assignment (constant force). Again, all of these assignments were written by the incredible Danny Cabellero and Balachandra Suri. (What, you haven’t offered Danny a job yet? Better get on that.)

View this document on Scribd

And this time the kids sailed through the project. So much so that I said, ok, it’s time to do something cool. Here’s some examples of what we got.

One group asked—what if I wanted to make a spaceship, that had lots of parts, link engines, windows, etc. Could I somehow make all those parts move together? YES! you can, it’s called object oriented design.

Another group learned about textures in vypthon and produced this wood textured marble.

Another group made a model of a car.

One group wrote a program to model a game of chicken between a CVPM car and a CAPM bus, and drop an arrow when the two hit each other. It was awesome to watch three girls troubleshoot their way through the logic of the if statement to make this happen. Here’s the video:

So none of these programs will wow Donald Knuth, but the important thing to keep in mind is that that the kids are discovering for themselves what they want to do. I didn’t teach anything about textures, or how to combine objects, how to model projectile motion. The students are figuring it out own their own.

But perhaps most impressively from a physics perspective, one group made a model of a ball being thrown into the air. It took them almost no time to realize that with a simple change, they could make the ball move on a parabolic path, but giving it some horizontal velocity. And since they had set the ball to draw breadcrumbs as the ball moved, these two students were able to figure out that the horizontal component velocity of the ball follows CVPM, while the vertical component follows CAPM. Can you imagine how awesome this is going to be when we figure out the physics of Angry Birds? (Thanks Rhett, for giving me the idea for the coolest lab ever).

Yes, now I think I’m starting to see the power of computational thinking.

1. January 10, 2011 1:14 am

Nice. I probably would have done that stuff in scratch rather than vpython, since it is only 2D, but it is still a good way to teach physics.

• January 10, 2011 9:17 am

Scratch is awesome, and I really wish we would introduce it to students in the middle school. I’m hoping to actually do some 3D stuff with my guys, so vpython seems like the right fit, and I worry that since they think they are cool high school students, scratch might look a little childish for them. Python gets them feeling a bit closer to being a real programmer, even if they have lots of trouble tracking down the various syntax errors they make.

2. January 10, 2011 8:55 am

Excellent! I’ve often wondered if a spreadsheet approach or a repetitive manually calculated updates would be best to do first before any actual programming.

Either way, it’s nice to see you are doing this in your 9th grade classes. I just haven’t had the time to try to implement Danny’s stuff yet with my students.

Keep us posted!

• January 10, 2011 9:21 am

We used to do numerical integration with excel with our honors physics students at my old school. As teachers we loved it, but the kids really had a hard time with it. I think there’s something about opening up an excel file filled with numbers and just being overwhelmed.

We did have a great assignment for teaching 1/r gravitational potential, where they would simulate a ball falling to the surface of the earth from 2 earth radii away, compute the work done by the gravitational force over small distances, and add them all up to get the change in potential energy. And so kids could figure out gravitational potential as 10th graders, without calculus. If we have the time, I’m going to try this with my 9th graders and vpython, where hopefully it should be a bit clearer to understand.

• January 10, 2011 10:57 am

Spreadsheets are a truly terrible programming language. It
is much easier to write a Python program than to pummel Excel into
doing a similar task. vpython is a good choice if you want to do
3D. I taught a short Scratch class a couple summers ago to a mixed
group of middle-school and high-school students. A couple thought
it would be childish when they started, but they really got into it
when they saw what they could do with it.