And now the simulation animation looks like this (there’s some extra annotation that I’ll talk about below):

Note first that the system never gets above the dotted green line, which was my (mistaken) idea from the last post. This post will try to talk about what I learned about whether the normal force does any work (which was my mistaken explanation in the last post).

The track exerts a force on the red ball to keep it on the track. Gravity and the connection to the first black ball are yanking on that ball and the track does whatever it has to in order to ensure that the red ball stays on the track. My argument from the last post boils down to this: The normal force is an external force to the system of three balls. That system has a center of mass that I can pretend the external force acts on. If the center of mass is moving perpendicularly to the normal force (as would happen with just the red bead), there would be no work. But if the center of mass is moving at times slightly parallel to the normal force, then there would be some work. It turns out there’s really nothing wrong with that description. However, assuming that changes the kinetic energy of the system is wrong. What it does (as again my friend Craig suggested) is it changes the *translational* kinetic energy of the system (basically the kinetic energy of the system if you replaced it with all the mass being at the center of mass). However, the total kinetic energy of the system is both the translational and rotational kinetic energy. What I intend to discuss here is that the effect on the rotational kinetic energy due to the normal force is *exactly the opposite* of the effect on the translational kinetic energy.

First a quick plot. This shows in blue the time derivative of the translational kinetic energy of the system (subtracting out the effects of gravity) and in orange the work per unit time that the normal force does on the system:

Actually, you don’t see the orange because, to the accuracy of the thickness of the lines, the orange is completely underneath the blue.

Let’s try to understand what’s going on. Consider first the time rate of change of the kinetic energy of the system:

The derivative can come right into the sum, and the vector product rule gives us:

where I’ve used Newton’s second law in the last step. Now the normal force is only “attached” to the red bead, but that’s the one bead that’s guaranteed to be moving perpendicular to the normal force. So the contribution to the time change of kinetic energy due to the normal force is indeed zero! Hence my last post is wrong.

But what about this business with the translational kinetic energy? We tell our students all the time that they can think of all forces as acting on the center of mass. In other words, the change of momentum of the center of mass is due to the collection of all external forces. Those forces will do work if they act, at least partially, in the direction that the center of mass is traveling. In the animation above the purple arrow shows the direction that the center of mass is traveling. You can see that it doesn’t always point along the track. That means that it’s not always perpendicular to the normal force. Hence work is done on the center of mass. But that just affects the translation of that center of mass, not any rotation about it. To see the whole story, let’s redo the last calculation using a coordinate system centered on the center of mass. For those variables, I’ll use primes. First I’ll start with an expression for the kinetic energy:

Now when you do the FOIL of that dot product, two of the terms go to zero (that’s the beauty of using the center of mass, by the way) and you’re left with:

where M is the total mass of the system and V is the velocity of the center of mass. Now, let’s consider doing a time derivative of that. For the first term you’ll get exactly what I was talking about above. In other words you’ll get the dot product of the total external forces and the velocity of the center of mass.

Now here’s a trick. Let’s re-express the velocity back into the normal frame (and use Newton’s second law again) for the second term above:

Here’s where the magic happens. The normal force is only applied to the particle on the track. But it’s velocity is perpendicular to the normal force by definition. So the first term in the parenthesis yields a zero. What we’re left with is:

which is exactly the opposite of the change to the translational energy. In other words, you can either say that, yes, the normal force does some work, but it changes the translational kinetic energy by exactly an amount that is the opposite of how it changes the rotational kinetic energy, or you can just say that the normal force does no work. You decide.

Thoughts? Here are some starters for you:

- Thanks for this, I was totally at a loss for figuring out the mistakes in the last post.
- I’m glad you figured this out for yourself, just know that the rest of us knew this all along and have been laughing at you for your last post for a few days now.
- Wait, it doesn’t work!? I’ve already starting building it in my backyard!
- How did you figure out the normal force? Did you determine the accelerations of all the particles and subtract all known forces, starting with the last black dot and moving up to the red dot. Or did you use Lagrange multipliers to figure out the normal force more directly, and, if so, how did you figure out the constraint equations for the track? (yes, yes, and it’s a long but interesting story involving me jumping out of bed this morning and trying something that worked!)
- So how would you say it? Does the track do work on the system?
- How is it that you were willing to believe that the track could help you violate energy conservation? What, are you some sort of “momentum is king” kind of guy or something?

]]>

Here’s the animation that got me thinking:

Take a look at how high the whole system gets compared with the original height. It sure looks like it ends up a little higher. Where does that energy come from?

Why I was wrong: I think I had it in my head that the track which provides the constraint force never does any work. That’s certainly true for the case of a single bead on a wire as the normal force is always perpendicular to the direction of travel, hence no work. But in this case that’s not true! Instead, the normal force is at times not perfectly perpendicular to the direction of travel of the center of mass of the system. You can see that in this annotated version of the animation where I track the center of mass in green and show the initial height as a dotted line:

Cool, huh?

Your thoughts? Here are some starters for you:

- Thanks, this is very cool. Can you find the same thing with a single pendulum on a track?
- This is old news. Designers of hang-under coasters take this into account all the time.
- Can you post the Mathematica code? (yes: here you go)
- Can you figure out the normal force of the track using Lagrange multipliers? (note: I can’t figure out a way to parametrize the loop as a constraint that looks like g(x,y)=0)
- Why do you always post animated gifs. Don’t you know people hate those?
- I think your code is wrong. There’s no way the center of mass can get up higher than it starts.

]]>

I made a lot of progress on how to teach Lagrange multipliers the last time I taught this class, and I have to say that it was great being able to read my old thoughts when prepping this class. In that post I break down how to derive the needed result, so I won’t repeat that here (though I did find a slightly better approach for one of the steps that I’ll talk about below).

So why was I waffling? Every time I come around to this topic, I begin to realize that if my students are predominantly going to numerically integrate the ultimate equations of motion (or equation of motions as I usually pluralize the acronym – eoms) they can get the same information that Lagrange multipliers provide (typically the constraint forces) by simply plotting the total acceleration of the relevant particles minus the known forces. In fact that’s one of the beauties of the Lagrangian approach — you can ignore the constraint forces when figuring out the equations of motion. At the end of the day, you have access to the full accelerations which come about due to both the known external forces AND the constraint forces. What Lagrangian multipliers do is help you explicitly calculate those constraint forces, but sometimes I don’t really see the value of that.

So what tipped the scales towards teaching them this year? Well, I realized that actually doing what I suggest above is kind of a hassle. Consider the prototypical problem of when a sled will lose contact with the ground as it goes down a hill. If you have the equation of the hill, you can then reduce the problem to a one-dimensional one, typically the horizontal variable. Then you can do the Lagrangian approach where you force the sled to stay on the curve. When you’re done you can look at the total acceleration and subtract gravity from that vector. Then you have the normal force vector and you can investigate when that switches from a vector pointing out of the ground to a vector pointing into the ground. When that happens the sled will lose contact with the ground. Now, that all sounds great, but actually determining which way the vector points involves dotting it with a vector that’s normal to the curve. To get that you have to do some derivatives on the function that defines the curve in the first place. In other words, there’s a little bit of a hassle.

Contrast that with learning about Lagrange multipliers and applying them. Now, there’s no question that learning about them (the whole separation of variables thing in my other post) is not a cake walk. However, there’s some very cool calculus of variations in there and it helps me reinforce the original derivation of the Euler equation (which I always choose to teach). So teaching it isn’t really the big deal. What is the big deal is whether what you get after implementing it makes your life easier. And guess what? It does! For the sled problem, if you have access to the Lagrange multiplier as a function of time (which you will after implementing the approach) you just have to plot it and look for when it changes sign. That doesn’t require the multivariable calculus that’s necessary to define the normal direction that you need for the other way.

Here’s the screencasts that I made for my students today. We were tackling whether a sled would ever lose contact with the ground on a parabolic hill. I did it once without Lagrange multipliers and once with them. It’s my contention that the second way is a more clear way of finding when the sled leaves the ground (too long, didn’t watch: it never does for a parabolic hill). But I recognize it’s not a slam dunk case.

I was talking with a math professor buddy of mine today and he suggested that it might be a slam dunk case if you have a constraint that is hard to solve for one variable in terms of the other. I get what he was saying, but I don’t immediately have an idea of a sled/hill constraint where that would be the case.

Quick note about a change to the derivation: There’s a point in my other post where I say that the constraint should not be a function of the perturbation variable, . I then take a derivative and find a relationship between the two perturbation functions, and . I realized this time around that there’s a different way to approach that. Basically we know that the constraint, g, has to be obeyed whether you’re on the best paths (x(t) and y(t)) or on nearby paths ( and ):

$latex g(x_b+\alpha \eta_1, y_b+\alpha \eta_2) \approx g(x_b, y_b)+\frac{\partial g}{\partial x}(\alpha \eta_1)+\frac{\partial g}{\partial y}(\alpha \eta_1)$

or

$latex \frac{\partial g}{\partial x}(\alpha \eta_1)+\frac{\partial g}{\partial x}(\alpha \eta_1)=0&s=2$

which leads directly to the same result I have in the last page.

Update on how to do this in Mathematica: In the screencasts above you might notice that I deviate from what I suggest in my other post. The reason is that Mathematica has a new method for NDSolve that saves the day. Now you can simply tell NDSolve about the constraint and go, without having to do the differentiation that was my work around. The key is to use Method->{“IndexReduction”->Automatic} which Mathematica kindly suggests if you try to do NDSolve without it. It’s great, you even only have to give initial conditions for one of the variables. Mathematica will figure out the initial conditions for the other variable(s) by using the constraint. Awesome!

Your thoughts? Here are some starters for you:

- I like this, I’ve been looking for better motivation and I’m going to use this to . . .
- I hate this and all things having to do with Lagrange multipliers. Please stop posting about this.
- I’m in this class and I found today very useful. Here’s why . . .
- I’m in this class and I thought today was a waste of time. Here’s why . . .
- Of course you don’t leave the ground on a parabolic hill, everyone knows that.
- Why didn’t you type up all the stuff you said in the screencasts? I hate watching videos.
- Thanks for the screencasts, do your students find them useful?
- Mathematica had that new method two years ago, I just decided not to tell you about it
- Here’s a suggestion for a sled/hill problem with a constraint that’s hard to solve for one of the variables . . .

]]>

I was thinking about the oral exams today as I was grading some of the screencast submissions from my students on the “I can derive the Euler/Lagrange equation” standard. A few of them had pretty good derivations, but there were tiny issues that I was disappointed to see that they didn’t nail. My first inclination was to give a “3 improvable” meaning that they could just try to figure out the tiny thing I care about to turn that into a 4 (the highest score on my Frank Noschese rubric). But then I remembered the oral exams and realized that I could give them 4s now but lay into whoever gets that standard for the oral exams next week. Every standard will be done roughly four times next week, so the whole class will be able to hear my tiny issues discussed.

I want to be clear here. I’m not saying that I’m giving them a good score now only to blast them next week. Instead I’m trying to really reflect on my rubric. If I’d brag about it, or it seems they could teach it well, that means they get a four. That’s not the same as saying they can do every single tiny detail that I have learned to watch for after teaching this course six times.

I also thought about the role oral exams play in some of the resource screencasts I make for the students. Today we were talking about applying the Euler/Lagrange approach to multi-dimensional problems and I offered up that I could fill in the details of the derivation if they weren’t super comfortable with just saying “ah, ok, I could believe that you’d get the same equation for every variable.” At the end of the day our “I can” statement was “I can do an interesting multi-dimensional Lagrangian problem” so when I sat down to do the screencast, I realized that it really was only needed if the standard had ended up being “I can derive . . .” But that’s when it hit me that the students who ~~watch~~ study that screencast are going to be much better off if they get that standard in the oral exam. They’ll have a “interesting” problem worked out, but I might just ask why they can use that differential equation in the first place. Is it fair? You bet! They need to know this stuff. They need to know where it comes from and why it matters, not just how to turn the crank.

How do oral exams help your teaching? Here’s some starters for you:

- I like this approach. I think for my oral exams next time I’ll . . .
- I’m in this class and I think this is great. I think it especially makes sense for the standard on . . .
- I’m in this class and I think this is dumb. It’s a double standard! If you want us to know the tiny details, you should lay them all out for us so that we can just read them back for you.
- What percentage of your students
~~study~~watch your screencasts? - Five minutes! That’s awesome and here’s why . . .
- Five minutes! That’s ridiculous and here’s why . . .

]]>

First the piano. I play the trombone and the guitar (chords only, really) and I sing quite a bit. I play in my school’s jazz band so I’ve been trying to get a little more music theory under my belt over the last few years to help my improvisational skills. However, I’ve never learned how to play the piano. I never had lessons and I’ve never had a piano in the house to get me to start taking it more seriously. That changed this past Christmas when we decided to buy our son a keyboard since he desperately wants to learn how to play. So now we have a keyboard in the house and I figured I could try to teach myself.

I started with the books that he’s using, but a lot of it is basic musicianship that I don’t need. So I looked at the book that came with the keyboard and have been slowly working through it for the last month. It uses the basic 5-finger approach with an occasional cross-over. Here’s me butchering the piece I’ve been working on for a couple weeks:

As you can tell, I suck. But that’s to be expected here at the beginning, right? And the piece is boring, but I can’t ask for more at this point, can I?

I was getting a little bored with those pieces, so I asked youtube for other things to work on. I found some pretty cool videos about boogie woogie piano and realized that getting the chords under my fingers could really help out. After a few days I can now reliably play basic triad chords in every key with either hand.

Jump to today. I talk below about the jazz teaching I’ve been doing, but I needed a song to work on with them today and Watermelon Man was playing on the radio as I was driving and I figured that would be a good one. It’s a 16-bar blues form which is a little different than the standard 12-bar blues stuff we’ve been doing, and it has a pretty easy head to teach. So I came home and asked the internet what the chords were. I found a version of the score and sat down at the keyboard. Within a half-hour I could do this (adding in the built in rhythm tracks that the Casio keyboard provides and changing the voicing to “jazz organ”):

I’m pretty proud of myself, and I’ve been going back to play it all day since it’s so much fun. It’s complicated, using both hands with different rhythms, but it’s repetitive and it’s easy to get myself back on track. It’s also pretty catchy given that my whole family is humming it tonight.

On to teaching jazz. My son’s school has a jazz program that isn’t big enough to let everyone who’s interested to play so I thought it would be fun to have some of his friends over once a week to work on simple jazz ideas. No sheet music, just basic forms like 12-bar blues in the ubiquitous B-flat key (though a few non-C-instruments show up so I have to really concentrate to tell them what notes to play). Not too many come over, but we have fun no matter who shows up.

Today was pretty typical. I told them about Watermelon man, played the keyboard backgrounds, and then taught them the head. The caught on pretty quickly and we just kept playing it with a little improv thrown in. I had the sheet music, but I didn’t show it to them. I wanted them to get it by ear. I think the sheet music would have helped them find the notes, but my suspicion is that they got the rhythm down better by just listening than by looking at it.

Ok, so on to some potential analogies and questions. I’ve numbered them to help with any help/comments/questions you might have:

- Learning a 5-finger song is like doing a textbook problem that no one cares about
- practicing it will get me better, but I don’t have any fun

- Learning Watermelon Man was like . . . I’m not sure. It was fun, and I did it fast. I used sheet music, but only to get the chords in the first place, from then on it was because I knew the song.
- Being able to skip the beginners books due to my other music knowledge is like a student being able to skip general physics in college thanks to her high school physics class.
- Teaching things like 12-bar blues without sheet music is like asking students to explain everyday phenomena with their own vocabulary.
- Often I’d just play notes and they’d have to noodle around to find what I was doing.

- Helping students develop improvisational skills is like . . . I’m not sure. There’s a structure they have to know (here are the “safe” notes you can fall back on) but there’s tons of freedom and no “wrong answers”

Here are some comment starters for you:

- Man, you really suck. Why would you post recordings of your bad playing?
- I like analogies X and Y because . . .
- I don’t like analogies Q and Z because . . .
- Here’s a way to finish your analogies . . .
- What time is “Jazz at the Rundquists”? I’d like to come over with my . . .
- The differences you mention between the 5-finger stuff and the chord stuff doesn’t make any sense. They’re completely different types of playing and they don’t support each other at all. Here’s what you should do instead . . .
- We’ve got a gig coming up, are you free?

]]>

They mentioned that they liked the sound unit because we constantly were using examples from their lives to explain things. One example that comes to mind was when I asked them when in their lives they realized that sound didn’t travel infinitely fast. For me it was walking my dog in the outfield of a softball team practice. For others it’s thunder, or a professional baseball game, or whatever. Given the comments from those few students above, I think I want to make sure that I keep doing that kind of thing in class.

I don’t teach the first semester, but I certainly know that my own experience in general physics 1 was not overly related to my life. I remember not being convinced of forces because they didn’t explain pillows to me.

Anyways, I just wanted to get this thought down to remind myself in the future. Your thoughts? Here are some starters for you:

- I was one of those students and you totally misunderstood me. What I meant was . . .
- I was one of those students and what you forgot to mention was . . .
- My students always like the 2nd term material better. I think it’s because . . .
- Weird, my students always like the 1st term material better. I think you’re doing it all wrong by . . .
- This is a woefully short post. Try getting your thoughts together better before firing up WordPress. Here’s a few starters for you . . .
- I jump into modern physics topics right away. You’re a fool not to. Everything you’re teaching is centuries old! Here’s how to fix it. . .
- Great, another batch of students who think that the circuits in their house are DC and other big problems like . . .

]]>

DISCLAIMER: I’m writing this post on the day after the quiz, but two days before I grade the quiz. I’m doing that because I’m still excited about this experiment now, and I might not be so much after grading the quiz.

The topic was diffraction and resolution. We explored ways to add phasors, who all have the same phase relationship, to achieve a dark spot. For example, for 4 phasors you have a clockwise square, a counter-clockwise square, and what we called “back and forth and back and forth.” There’s only 3 ways to add to zero with four phasors and that helps explain why a quadruple slit has two sub-peaks between the main peaks in the diffraction pattern. For resolution we talked about how far apart things have to be for us to discern that there’s actually two things there. I felt that both classes went pretty well. We talked about finite numbers of phasors and infinite numbers (like in a single slit) and multiple infinities (like in realistic multiple slits). I was especially happy with using the infinite phasor argument to explain why a single slit would lead to dark spots.

In lab my colleagues made available a plate with 25 different slit configurations and two different color laser pointers. There were also boards to act as screens. I told the students that they should definitely investigate all 25 with both colors and record whatever they thought would help them on the quiz. One thing I specifically encouraged was to look for “missing orders” where the single slit dark prediction coincides with the multiple slit bright prediction.

The quiz consisted of these three prompts:

- Describe your hunt for “missing orders.”
- What logistical challenges were there in lab?
- Considering the theory we developed in class this week, what other investigations would you like to do in lab if logistical/financial/temporal concerns could be ignored?

The standards that were going to be assessed on the quiz were:

- I can calculate the location of peaks for multiple slits and zeros for single slits using phasor ideas.
- I can find where missing orders would be and discuss imaging resolution.

When I started the quiz I said “hopefully your answers to the prompts will help me identify whether you’ve mastered these standards.” I did that because I was a little worried that they’d talk about things that happened in lab that wouldn’t really have much to do with the standards. For the logistical one I was hoping for issues that could be connected to the theory of diffraction. For example something like “we realized that putting the screen further away would have helped identify the spacing of bright spots, but we could only move it so far away on our table.” I also hoped that the last prompt would solicit comments about resolution, since the lab was really mostly about the multiple slit diffraction standard.

So, we’ll see. I’ll grade them Monday and maybe I’ll augment this post at that point. For the moment I think it went pretty well. I talked with some students after lab and asked what they thought. The comments ranged from “it was easier than most labs because I didn’t have to do every single measurement” to “I didn’t really know what to do in lab.” I think I’m ok with both of those extremes.

Your thoughts? Here are some prompts for you:

- I’m in this class and I thought this was a good lab experience. What I really liked was . . .
- I’m in this class and I didn’t like this at all. It would have been better if we had . . .
- Why didn’t you give them some 2D diffraction targets?
- Here’s a great lab setup to get at the resolution standard . . .
- What would the lab have been like if you hadn’t made this change?
- Here’s what I predict will make you crabby when you grade the quizzes . . .
- Here’s what I predict will make you laugh when you grade the quizzes . . .
- Here’s what I predict will make you not update this post after you grade the quizzes . . .
- I like your phasor approach. Can you use it to explain how bright the sub-peaks will be?

]]>

So what have I learned? First, it’s been fun to be a part of so many different conversations. Most of my comments lead to some kind of interaction with the author, and a few led to a conversation with other readers. Oddly it felt like a little less conversation than last year, but I haven’t really carefully compared.

Second, I HATE BLOGGER! Ok, that was a little strong, but I really hate having to remember to copy my comment just in case the whole verification thing loses my comment. I also hate that the default Blogger blogs don’t have the incredibly handy “notify me of responses via email” checkbox that is the default for wordpress blogs.

Third, I put way more effort into finding a new blog (that was published on that day!) than I did to just being a productive/supportive member of my usual Professional Learning Community (also known as my tweeps and blog rss feed). It was a busier-than-average month for me (lots of jazz band rehearsals etc) so there were many nights when I just wanted to find a new physics/teaching/highered blog that I could comment on. That differs a lot from my usual “oooh, what are people up to/hey I need some help with something” approach that I take. There’s no question I wanted to accomplish my goal, and I’m glad I did, but it’s funny that the reason for the goal was community building and I think I actually pulled back a little from my community by doing it.

Your thoughts? Here are some starters for you:

- I can’t believe you hate Blogger. That’s it, I’m never reading your stuff again.
- In your old post, you suggest asking a question in your comments. Did you get your questions answered?
- I wrote one of those blog posts and was so happy to see your comment. I was especially pleased with . . .
- I wrote one of those blog posts and I would greatly appreciate it if you took it off this page. I greatly disliked your comment and really want nothing more to do with you. You should spend your time instead . . .
- I wrote 17 posts this month and you didn’t comment on any of them. What’s the deal?
- I coined #NaBloCoMo years ago so stop using it for National Blog Comment Month. It clearly stands for . . .

]]>

In principle this is a cool lab (and not as sadistic as the ones that electrify goldfish bowls trying to get the fish to line up on equipotentials to minimize the pain). However, for me, it has some problems. First, it’s not an electrostatic situation. We don’t have charged locations on the paper, so saying that it’s measuring potentials and fields is not correct. Instead it’s a very complex circuit with current flowing in all kinds of weird ways. Second the best analogy is with infinite lines of charge, instead of point charges. I find it hard to get students to understand that, mostly because they can see that it really doesn’t have infinite lines of charge sticking out of it.

I wanted to see how good that analogy was, so I set out to calculate the current flow through the paper. I first did some thinking about doing this while considering the paper to be a continuous resistor. Unfortunately I’ve only had success doing that sort of thing for very symmetric situations like a cone-shaped resistor (a popular homework problem that has problems of its own). So I decided to look into what it would take to model the paper as a grid of resistors. Here’s a sample of the model I built:

Ultimately I settled on a 30×30 grid as a compromise between good resolution and speed of calculation (everything below takes ~3 seconds to run on my Surface Pro 2).

Using an approach I’ve talked about before, I set out to figure out what equations I could use to solve for the unknowns (all the currents and all the voltages at the grid points). Here’s what I came up with:

- For every node points: current coming down from above + current coming in from the left = current leaving going down+current leaving going right
- For every node point: V[{i,j}]=V[{i+1,j}]+currentdown[{i,j}]*R (I set R to 1)
- For every node point: V[{i,j}]=V[{i,j+1}]+currentright[{i,j}]*R

I had to do some careful work around the edges, and I had to set one location to the voltage of the power supply (I used 1 Volt) and another to zero. I also had to name the current through the battery as an unknown.

All together I have 2642 equations and 2641 unknowns. Mathematica is then happy to oblige. Here’s a plot that has a lot of information. Color is the potential at every point. The thick black lines are equipotentials. The arrows are the direction of current at each point (really a vector of both currentdown and currentright). The opacity of the arrows is the strength of the current.

Pretty cool, huh. The image is done with a single command in Mathematica called ListStreamDensityPlot. Awesome.

Ok, so how about the analogy? Here’s a comparison of the voltage along a line that connects the red and blue points. Blue is the results of this calculation. Red is the best fit for the potential due to a positively charged infinite line of charge coming out of the paper at the red point and a negative one at the blue point. Green is the best fit for the potential of point charges at red and blue.

By my eye the red fit is much better, at least in the interior. I actually expected some discrepancies near the border of the grid anyways.

So, here’s my question: is this a good lab to do? I’m not convinced. Yes, there’s a decent analogy with something the students could do as homework, but the physics is very different (current is flowing in this case, for example).

Your thoughts? Some starters for you:

- I’m in this class and I thought it was a great lab. Here’s why . . .
- I’m in this class and I’m supposed to be studying for my oral exam right now, not reading this!
- Wait, what did you say about goldfish?!
- Can you give more details about what you did around the edges?
- Can you give us your code?
- I do this lab and think it’s great. Here’s how I handle your objections . . .
- I hate this lab and am glad I have this to point to in the future, thanks!
- Can you do more interesting designs like we do in lab? Bars of connected points all at the + voltage, circles, etc?
- How did you define your zero of potential for the infinite lines of charge? Doesn’t the log function get you into trouble?
- I’ve talked about this at length and I can’t believe you didn’t link to me, jerk.

]]>

My approach to solving this problems involves my go-to tool for lots of hard problems: a genetic algorithm. Basically I try a random set of solutions, rank them based on the distance each takes, and I randomly choose them (with weights determined from their “fitness” or distance) to make babies by mutating them (switching two points in the visit order). I make lots of babies and then choose the best ones to populate the next generation. This tool is quite versatile as you just have to define a fitness function that returns a rankable value and you have to carefully determine what the genome structure is and what mutation is. Then you’re off and running. Note that I didn’t do any sexual reproduction as I didn’t have any good ideas for how to do that in this situation (though my friend Jon Gaffney did send me some great resources for that).

I also decided to throw a wrench in. For fun I had the locations on the map slowly move around, using basically a random walk for each. I did that so that I can show this to my First Year Seminar students to talk about how evolution can handle a changing landscape (their summer reading book was Paleofantasy and their assignment was to find a connection between that book and engineering – most are either agreeing or disagreeing with the notion that evolution is an example of engineering).

Here’s a gif showing the best candidate at the end of each generation (one frame for each generation).

And here’s a plot showing the fitnesses of every candidate in every generation:

As you can see, it converges rather nicely, thought the spread in candidates never goes to zero because the dots are constantly moving. To show that it can handle an abrupt change to the environment, here’s a gif showing a situation where the points are randomly shifted to a new location halfway through:

and here’s the plot of the fitness versus generation (note the spike when the points move):

Finally, I thought I’d have some fun with river crossings. I decided to see what would happen if I put in some rivers (line segments) and charged a huge cost (10 meters) for crossing them. Here’s an example:

Here the plot of fitness versus generation really just shows when extra crossings get added:

Fun huh?

So, how can we quantify the value of this approach. Here’s on way: compare to a blind hunt. I could just randomly create paths (really just randomizing a list of integers from 1 to the number of points) and constantly check their fitness. Here’s what a histogram looks like for a set of points with a “best path” fitness around 9:

Note how gaussian it looks. It has a mean of 22 and a standard deviation of about 2. That means that the “best” is more than six standard deviations away from the mean. What are the chances of getting that randomly (assuming the normal distribution holds, which is surely doesn’t but whatever)? That’s just a relatively straightforward statistics calculation that leads to an answer of 37 billion to one against. Another way to say it is that you’d have to run billions of random tests to have a decent chance of getting a “close-to-best” path.

Now, that last paragraph suffers from a huge assumption about the distribution staying normal (or gaussian), so here’s another way to think of it. My genetic algorithm runs 200 generations with 50 kids per generation. That’s 10000 different tests. What percentage of all the possible paths is that? Well that’s easy: 10000 divided by 20 factorial (because I’m currently using 20 points). That gives a value of 0.000000000004% (also known as basically zero). So I think the genetic algorithm is doing a very efficient job for this problem.

Thoughts? Here’s some starters for you:

- I’m in your fysem (first year seminar) and I think this is really cool. I’m going to change my paper to . . .
- I’m in your fysem and this is dumb. Just another example of why I should have dropped this class.
- How did you do this in Mathematica? Can you share your code?
- If your friend Jon has already done this, why are you trying to steal his thunder?
- If another friend has done a ton of work on this too, why haven’t you at least linked to his tweets?
- Your assumption that the distribution stays gaussian is stupid. Instead you should . . .
- How do you know you’re not in a local minimum? I can see in a few of the gifs that there are still some crossed paths and that means you’re not at a minimum.
- You speak of evolution as if were more than a theory, why do you do that?
- You’re such a fan of brute force approaches, why don’t you just do all 20! versions?
- Why didn’t you have the rivers moving too? Or have curved rivers? Or wide rivers?
- Why a cost of 10 meters for a crossing? That’s just dumb. Instead I would . . .
- In the traveling salesperson problem the visit points should not be moving. This is an abomination.

]]>