Creating supplemental texts

I’m nearing the end of a semester where, for one class, there was no official text. That’s going decently well, though I’ll likely have more to say about that in another post. What I want to talk about here are some avenues I’ve been exploring to produce supplementary reading material for my students. Often the text I’m using doesn’t quite say enough about something, or I can’t find an online resource that attacks a topic in the way I would like to see, so I try to make my own for my students. I’ve been trying several different approaches for that, and I thought I’d reach out to you to figure out if I’m forgetting any issues, or, even better, a whole new approach.

What I really want

Here are the features that I’m looking for. Please add any others that are important to you in the comments:

  1. Nice pdfs
  2. Nice html
  3. Ease of editing
  4. Easy hyperlinking/navigation
    1. For external links
    2. For internal links
      1. sections
      2. equations
      3. figures
  5. Equation numbers (that are automatically numbered)
  6. Ease of building in interactivity
    1. this can be in the form of links to things like the PhET simulations
    2. But they can also be easily created by me

Home built LMS

Several years ago, I finally decided that I’d had it with Blackboard. So I wrote down what I wanted/needed for a learning management system, and I built my own, using php/mysql. It includes

  • A place for notes for each class day. I call those daily outlines, and I often pull them up in class. Here’s an example. It shows how I can (easily) build in links, and \LaTeX. It also interfaces with my grade book to show what’s been assigned and what’s due.
  • A page to edit for the syllabus, where I can also edit the titles of all the daily outlines
  • A grade book that allows for a very flexible set of algorithms (even some invented for a particular class).
  • The ability to collect daily summaries and outlines from my students

It does the job, but it really falls down with internal hyperlinking, equation numbering, figures, and interactivity. I used to put a lot of webMathematica into them, but we’ve lost support for that, and it was relatively difficult to make those as well.

LaTeX

I would guess that many people would see my list above and jump to the conclusion that LaTeX is the way to go. I would simply point out that interactivity is out (except for the linking kind), and ease of use is a little down as well. Here’s an example: I can make an equation in Mathematica much faster than I can in LaTeX, even though I’m pretty fast at the latter from all the blogging that I do.

Also, LaTeX->html isn’t a fun experience. There’s latex2html, but it takes a while to run. It produces decent html, but it could use some better styling. Here’s a mini-text I wrote in LaTeX and then exported to html using that tool.

MultiMarkDown

MultiMarkDown provides the ability to write readable text documents that can then be separately converted to tex or html. I like it a lot, especially the styling you can do compared with latex2html, and I’ve been able to get the equation numbering and local hyperlinking to work quite well.

I was really sold on it a few weeks ago, but lately I’ve been realizing how many figures I make in other software (namely Mathematica, see below) that makes a clumsy workflow.

Computational Document Format

Wolfram Research (of Mathematica and Wolfram Alpha fame) created the Computational Document Format a few years ago. Basically, you can use the CDF reader to read documents created in Mathematica. Any interactivity you’ve built into the Mathematica document will still work in CDF, though simple Mathematica calculations that don’t have specific interactive elements will just show up as static calculations.

As I’m sure comes as no surprise, I use Mathematica all the time. I love all the keyboard shortcuts it has, allowing me to very rapidly typeset equations. What CDF does is allows me to author documents in this very powerful (and, yes, expensive) software, but deliver the results freely to anyone who downloads the CDF player.

I had long ago decided to stop using Mathematica to edit documents because it didn’t (as far as I knew) allow you to number equations and put in the type of internal links you could so easily do in LaTeX. I also assumed it couldn’t do bibtex integration (how I do bibliographies in LaTeX), figure captions, footnotes, and more. It turns out, I’ve been wrong (at least since Mathematica 8 came out), and CDF’s can do all of those things, most quite easily.

And, of course, you can put in all the figures and interactivity without worrying about exporting things. It’s all just right there. And, as long as you surround things with “Manipulate” commands, the interactivity will be available for your students.

It also opens up the possibility of changing up my “flipped class” approach. In fact, it would seem to put me in a position to do things similar to the UIUC physics department, that uses online tools for students to explore before coming to class ready to work on problem solving and ask questions. Now I have my students watch me play with most of these tools on videos that I create. I think it would be cool to give them all kinds of things to interact with, right in the text they’re reading, before coming to class.

Where am I now?

Well, you’ve probably been able to tell where I am now (CDF). But I’d love to hear about issues you think I’m either not giving enough attention to, or giving too much attention. As is my custom lately, here are some potential conversation starters:

  • PhET is great. Just posts links to that and let them play (as the PhET makers always suggest first).
  • Just have them buy a good text. Many are very well done, and have thought through many issues that you’ve only guessed at
  • You won’t provide a thorough enough “text” for them this way, so just put in additional links for them to augment their book
  • What!? You figured out how to get the equations numbered and hyperlinked in both the tex and html formats in multimarkdown? Share!
  • I assume your “wikipedia is my textbook” experiment has failed miserably, since you sidestepped that conversation in the first paragraph. Tell us the truth!
Posted in mathematica, syllabus creation, teaching | 17 Comments

Rigid body outline

I’m about to teach the dynamics of rigid bodies in my theoretical mechanics class, and I wanted to get down my plan. I developed and used this first a couple years ago, and I think I’m not going to change too much. Mostly it’s driven by the fact that most of my students in this class don’t take Linear Algebra.

  1. Study physical pendula This is a mix of reminding them what they’ve done with rigid bodies before, but also showing the Lagrangian approach for finding the period of oscillation. Some big ideas:
    1. The axis is fixed
    2. Size affects period for realistic pendula
    3. While the speed of every particle might be different, they’re all related to the angular frequency
    4. For the heck of it, I might ask them to analyze how frisbees can bounce, or why discs fade left for right-handed backhand throws.
  2. Consider L and omega There are lots of situations where the angular momentum and angular rotation vector are not parallel. Sometimes L is fixed and omega moves around it, and sometimes it’s the other way around. Omega is fixed if the axis is fixed (like step 1 above). L is fixed if there’s no torque (like free fall with tumbling). Big ideas:
    1. L isn’t always parallel to omega
    2. Wheel balancing saves the bearings that have to provide the torque if it’s unbalanced.
    3. Tumbling objects don’t always rotate around the same body axis
  3. Orientation Next we work out how to describe the orientation of an object (either about a fixed point or the center of mass if there is no fixed point). There’s the typical Euler rotations, but last time my students just worked out how to do it with the chairs in the room. It was funny because they picked a different “line of nodes” than our book did. It wasn’t their fault, it’s truly arbitrary. It meant I had to whip up some notes for them to show how the equations in the book changed, but it wasn’t that big of a deal for me to do that. Big ideas
    1. It takes 3 angles (actually, I’m not sure if that’s strictly true, but I feel like it must be, since 2 put the ultimate axis in place, and the third rotates about that).
    2. If something tumbles, the dynamical variables are those three angles
  4. Tackle a simple system We consider a system composed of a small number of masses that are rigidly connected. We figure out their position at any time by doing the appropriate rotations using the dynamical variables. This leads to a Lagrangian approach for those angles.
    1. The kinetic energy is a heck of an ugly expression involving the angles and the orientations of all the points.
    2. It doesn’t scale very well (8 points -> 10 seconds in Mathematica. 20 particles, more like a minute)
  5. Show a better way finally we get around to the inertia tensor, pointing out that the body frame is a much better way (computationally) to consider the problem.
    1. You have to do 6 sums with your particles. That’s it. It’s pretty fast, even for 100′s of particles. Their orientations are set and these 6 sums make up the (fixed) inertia tensor
    2. You have to re-describe the omega vector in the body frame. This is, by far, the hardest part.
    3. You solve it in the weird rotating body frame, but make pictures/animations in the lab frame. Luckily we’ve already done that (using the same variables) in step 4
  6. Revisit L vs omega The animations/simulations from the previous 2 steps show the complicated tumbling that can happen for non-symmetric systems. Why does that happen? Because the tensor isn’t diagonalized. So are there any axes you can rotate around that aren’t crazy? I have the students rotate the system, constantly recalculating the inertia tensor until they get zeros where they want them (they typically focus on the third column, since that’s how we’re set to spin the system). If you can get zeros (you can!), then you discover axes that won’t tumble strangely.
    1. You can find those zero’s systematically (it’s not just random hunting)
    2. Sometimes you get zeros and the system still tumbles crazily. That’s because you have small instabilities when rotating about the axis with the middle principle moment (middle as in the not the smallest nor largest value). This is the famous tennis racket problem (hold it so the face is pointing up and flip it (like a juggler). The racket will always twist in midair.
    3. For motion about those axes, L and omega are parallel
  7. Add torque Now look at systems with a fixed point and some initial rotation. You’ll see precession and nutation. Have fun!
    1. It’s a one line change in the code to add in gravitational torque. You just set the potential equal to m g times the height of the center of mass.
    2. You can look at Feynman’s idea of falling to precess.

 

Well, that’s the plan, anyways. Any thoughts? As is often my custom, some sample comments you can choose from:

  1. What the heck are you doing teaching this without Linear Algebra as a pre-requisite?
  2. Cool, how do you have them manipulate the structures to minimize the tensor terms?
  3. Whoa, wait, are you not deriving all the precession and nutation equations in class?
  4. How do your students figure out the orientation part?
Posted in physics, syllabus creation | Leave a comment

Planck challenge

I was giving an oral exam today in Modern Physics, and I was inspired to write this post. A student was up front doing this standard: “I can compare and contrast the Rayleigh Jeans and Planck approaches to Blackbody radiation.” She was doing a great job of explaining the two major pieces needed to do either calculation:

  1. Count the number of ways light can exist in a cavity. This is done by counting standing waves.
  2. Determine the energy in each way (or mode) of light. Rayleigh and Jeans say “Oh, every mode just gets kT on average, duh, just like 19th century physics tells us about systems that can share/swap energy.” Planck says “Well, let’s pretend that the oscillators in the walls can only have certain energies and see what happens. Huh, you don’t get kT anymore, you get a nasty formula that needs a constant. I think I’ll name it after me!”

The student did a great job talking about how the kT decision by R/J leads to the ultraviolet catastrophe (infinite amount of energy coming out of the blackbody, concentrated at the low end of wavelengths). Really, she did a great job with just about the whole conversation.

One thing I asked her about was whether R/J should have not bothered telling anyone their results, given that, while it fits long wavelengths well, it really messes up at small wavelengths. She thought it was still useful in certain circumstances, so, yeah, R/J should be proud. We then explored how similar that was to the notion that kinetic energy isn’t 1/2 m v^2 but that it’s useful in certain circumstances.

Then I asked if she would be brave enough to suggest Planck’s approach, given that he seemed to suggest that pendula can’t have any starting amplitude. She laughed and said she wasn’t sure, since she still has a hard time buying that.

So that leads to my challenge:

What if Planck had decided to make a crazy suggestion about how to count standing waves? In other words, leave the kT part alone, and come up with a crazy scheme for deciding which waves are allowed so that the data still fit.

I asked my student about this, and at first she said “but we know how many standing waves there are. If you said that some weren’t allowed for some crazy reason, it seems we could easily disprove that.” But I reminded her about the crazy notion that pendulum can’t have just any amplitude, and that launched a great discussion.

So, what do you think? Can you come up with a way to correct the standing wave count so that you can match the observed blackbody spectrum, assuming that each standing wave has an average of kT energy? How implausible would it be? Would it be “worse” than Planck’s approach?

Posted in physics, teaching | 2 Comments

Wait! It’s still interesting

A lot of the standards I have in my standards-based grading classes start with “I can do an interesting problem involving . . .” As a class we define “interesting” to mean lots of things, including that it hasn’t been done by us in class, by the book as an example, or by me in a screencast. Often it’s the “interesting-ness” that makes the difference between a 3 and a 4 on the rubric that I use.

This semester I’ve experimented with setting the standard for the day at the end of class, as I’ve written about before. That’s been working pretty well, both in Theoretical Mechanics and Modern Physics. Often, with ~5 minutes left in class, we take stock of what we’ve been up to (it’s a “flipped” or “inverted” class, so we’re using doing group problem solving) and decide on the standard. Often it becomes a vote between a philosophical/descriptive standard like “I can explain why we use complex numbers in quantum mechanics” and a problem solving/calculation-type standard like “I can calculate \Delta x \Delta p for a gaussian wave function.”

What I wanted to write about is what happened today. We were working together (in groups) on how to calculate expectation values of things given a wave function. We were tackling a gaussian wave function and asking things like what’s the average value of x or x squared. But then I realized that it was a cool problem, possibly even . . . “interesting.” So I stopped them and said “Wait! this is still interesting until we finish what we’re up to.” They voted to stop because they felt they understood the concept and wanted to show me they knew it rather than seeing it all the way through in class. Which, of course, would mean they’d have to apply it to a different problem on their own. We had just finished x and x squared and just getting started thinking about how we’d do p and p squared (that’s “p” as in “pomentum,” by the way). That’s the much harder part of this problem, mostly because it’s conceptually difficult to figure out the p-operator.

Some context: today was the last day before spring break, and, as this is an afternoon class, it was the last class for all of them today. I’ll admit that colored their vote a little, but not much.

They unanimously decided to stop and leave it as the standard. I asked if they felt confident they could finish, and they, to a person, said yes. So we left it.

So what are the pros and cons of this approach? Let’s do the cons first:

  • Of course they said yes, then they don’t have to re-apply the approach to a new situation.
  • They’ve been given a large fraction of the work for free (in their notes) to copy from.
  • They’re not shown the super cool result that a gaussian is the best you can do from the Heisenberg Uncertainty Principle perspective. Hopefully they’ll get it on their own, but will they take stock and notice?
  • Other (please add in the comments below)

Ok, now the pros:

  • They requested to not be spoon fed
  • They’ve been given some scaffolding for a difficult problem.
  • We got to get out of class early SPRING BREAK!!!!!
  • I can give individualized feedback to guide them to the aha moment about the Heisenberg point made above.
  • They get to debate with each other whether it’s better to see the end result or work on it on their own.
  • They see value in working on it on their own.
  • Other (please add in the comments below)

I’m pretty excited about this right now, but I know, for example, that the last “pro” above, especially, is likely wishful thinking. Rather, the first “con” above might be a better way to spin that.

So what do you think? Possible comment starters for you here:

  • You are spoon feeding them, giving them half the problem! Force them to apply tools to new systems!
  • This is cool, when is the best time to say “Wait! This is still interesting!”?
  • Seriously, what’s your hang up with complex numbers (ok, that’s for a few select readers, you know who you are).
  • Is the class debate dominated by people seeking to improve their learning or people trying to ease their workload?
  • Wait, you do flipped class? Don’t you know that’s the evilest evil that’s ever existed?
  • Wait, you do flipped class? Cool, how do you like it?
Posted in physics, sbar, sbg, teaching | 6 Comments

Imaginary quantum physics

A couple of years ago I wrote about some things I was thinking about regarding the use of complex numbers in quantum mechanics. This past week I got to refer to that post to my Modern Physics students, and this week we’ll work on the suggestion I made at the end of that post

I think interpreting those two equations is of interest as well. Essentially the spatial curvature of one produces temporal changes in the other and vice versa. That’s actually pretty cool as you could stare at a snapshot of both the two and predict what’s going to happen in the next moment of time.

Last week it was fun to ask my students about how weird they thought wave functions were when they considered that they were complex. We really haven’t gotten to the Schroedinger equation yet, but we have talked about de Broglie waves, and I mentioned that assuming they were cosine or sine waves was problematic from the probability perspective (\sin^2(x) as a probability density has a bunch of spots where you couldn’t find the so-called free particle). I showed them how e^{i x}  works out better in that regard, and then we had the conversation about the use of complex numbers.

Some of them had seen complex numbers used when talking about waves before. Of course, in those cases, it’s always used as an accounting trick, where we throw away the crazy imaginary parts at the end of the calculation. Here we seem to need to keep them.

I mentioned my old blog post, and we spent some time exploring why complex numbers bother them so much. (Note, at least one student made it clear that it didn’t bother him at all.) Mostly we landed on the fact that there’s so much cultural baggage around the word “imaginary.” So we spent some time exploring other ways to think about it.

I asked whether it would ever make sense that a farmer had 3+2i cows (I asked another first year seminar class a similar question, once, where we were talking about how human consciousness is going to change in the future). We decided that didn’t make any sense. Then I asked if it might make sense if I said I had 3+2i “pencils-and-pens” (spoken fast together). They said that they could interpret that as 3 pencils and 2 pens. Then we got talking about things that often get partnered up. One student suggested hot dogs and buns. What do you think? Does it make sense to say 3+2i “hot dogs and buns?” We were buying it, anyways.

What was interesting about that conversation is that I kept bringing it back to the wavefunction, asking if using the notion of keeping track of two things seemed less weird that a “complex” wavefunction. It seemed that it was.

I did point out the less-than-supportive comments on my last post on this. I was quick to tell them that some of those could be dispensed with if I admitted that the complex number approach is certainly a very handy way of doing things. But right now I care more about them buying into the fact that something is waving than knowing how to calculate things. That’ll come later.

Some of the other comments were also interesting. One talked about other non-spatial eigenfunctions, and, I agree, those are harder to deal with. Another talked about how you can get separate equations for the amplitude and phase of the wavefunction. I think that’s cool, but I’m really excited for the spatial stuff we can do this week using real and imaginary parts (see the quote above).

So, what do you think? Do you agree with our text that “you can’t ask what’s waving?” Do you ever say “wow, our universe has real and imaginary parts!”? What did you think about when you first learned about this?

Posted in physics, teaching | 1 Comment

Lagrange multipliers

This is a post that builds on my previous notes about the calculus of variations. This week I’m going to teach about modeling constraint forces using the Lagrangian approach, and I wanted to put these notes down for my current students and my future self.

Multiple variables

If you have a system with multiple variables, it’s pretty straightforward to convince yourself that the action is now the integral of a function of several functions and their slopes. Each variable will have a best path that minimizes the functional, with each best being surrounded by independent deviations that must all make the integral worse (larger, if you’re looking for a minimum). You can parametrize those deviations (the separate shapes of the deviations) with the same \alpha that we used before. When you minimize the integral according to \alpha you get

\frac{dJ}{d\alpha}=\int_{x_1}^{x_2}\left[\left(\frac{\partial f}{\partial y}-\frac{d}{dx}\frac{\partial f}{\partial y'}\right)\eta_1(x)+\left(\frac{\partial f}{\partial z}-\frac{d}{dx}\frac{\partial f}{\partial z'}\right)\eta_2(x)\right]\,dx

Now, if the deviations are truly independent, then the only way to make that be zero is to have the two things in the parentheses to be zero independently. Basically, you just get an Euler equation for both y and z.

Constraints

Ok, but what if the deviations aren’t independent (\eta_1 and \eta_2)? In other words, what if there are some additional constraints on y and z such that they need to conspire to keep the whole system on some sort of curve? We call that an additional constraint. It’s a pain because the trick we did above (setting both parentheses to zero) won’t work.

There’s two major ways of dealing with such a constraint. The first is to reparametrize your system, recognizing that you don’t really have two degrees of freedom, but rather one. If you do that, you reduce the problem to one dimension and you’re off and running. This is actually one of the big selling points of the Lagrangian approach to mechanics problems. The constraints in that case are usually constraining forces (like normal or tension forces) and it’s nice to be able to ignore them, especially since they usually don’t do any work (they force the constraint, which means they act perpendicular to the constraining surface, which the particle never leaves, hence no work).

The second way to deal with a constraint is what this post is all about. We want to be explicit about how the two \eta‘s are related to each other (if one changes, the other has to change in such a way as to make sure the constraint is still met). Maybe we can express one in terms of the other, being able to factor one out of the above equation, leaving behind something that has to be zero. That’s the game plan.

Buckle up, this gets a little nasty, but it’s worth it. In the end we’ll get a way of leveraging the constraint rules to be able to obtain not only the motion of the particle we care about, but also information about the forces ensuring the constraint in the first place. That latter information is lost in the first approach mentioned above.

First we have to have a way to mathematically talk about the constraint. Here’s the approach I’ll take: We’ll assume there’s a combination of y’s and z’s that must always be a constant: g(y, z)=constant. Note that often people like to put that as g(y,z)=0 by redefining g to have “-constant” in the definition. For how I’m going to use it, that’s not strictly necessary.

Next we need to force g not to change, even if \alpha changes. That’s easy, we’ll just say that dg/d \alpha is zero:

\frac{dg}{d\alpha}=\frac{\partial g}{\partial y}\frac{\partial y}{\partial \alpha}+\frac{\partial g}{\partial z}\frac{\partial z}{\partial \alpha}=\frac{\partial g}{\partial y}\eta_1(x)+\frac{\partial g}{\partial y}\eta_2(x)=0

where I’ve made use of some knowledge about the \eta‘s. Cool, I can solve that for \eta_2 in terms of \eta_1:

\eta_2(x)=-\frac{\frac{\partial g}{\partial y}}{\frac{\partial g}{\partial z}}\eta_1

Alright, now we’re in business. We can plug that into the first equation above and then be able to factor out \eta_1 out of the mix. Whatever’s leftover in the integrand has to be zero since \eta_1 can be anything. That leaves us with:

(sorry for the ugly pixelization, wordpress didn’t want to render it for some reason)

That’s pretty ugly, but, with some manipulation, we get a cool separation of variables:

where I’ve set both sides to a function that’s only a function of x (not y or z). Classic separation of variables approach.

Ok, then, we seem to have the newly modified Euler equation. For each variable we now have:

\frac{\partial f}{\partial y}-\frac{d}{dx}\frac{\partial f}{\partial y'}-\lambda(x)\frac{\partial g}{\partial y}=0

Oof, done. Now, what can we do with it?

Simple pendulum

Let’s apply this to a simple pendulum and see what we can do. First, we have to shift from the typical calculus of variations variables (y(x) and z(x)) to typical Lagrangian variables (x(t) and y(t)). The Euler-Lagrange (with constraint) equations will be:

\frac{\partial L}{\partial x}-\frac{d}{dx}\frac{\partial L}{\partial x'}-\lambda(t)\frac{\partial g}{\partial x}=0

and

\frac{\partial L}{\partial y}-\frac{d}{dx}\frac{\partial L}{\partial y'}-\lambda(t)\frac{\partial g}{\partial y}=0

where L is the Lagrangian (Kinetic energy – potential energy).

Ok, for a pendulum, we have x and y with a constraint that says the distance from the tether point (a convenient origin) should be the length of the string, a (I would love to use “ell” but it looks too much like a 1). So, a good constraint function would be:

g(x,y)=\sqrt{x^2+y^2}

Plugging and chugging gives us the following equations of motion:

m x''(t)=-\lambda(t) \frac{x}{\sqrt{x^2+y^2}}

and

m y''(t)=-mg-\lambda(t) \frac{y}{\sqrt{x^2+y^2}}

(please take note of the nasty double use of g in that derivation. Sorry about that).

If you stare at those long enough, you’ll see that \lambda(t) is really just the negative of the tension force of the string. That’s cool, and representative of what \lambda often turns out to be. Don’t be too bugged by the sign of the constraint force. Often we care most about when it goes to zero.

So, what did we learn? If you build in the constraints, you get equations of motion for more variables than the degrees of freedom of the system for the benefit of the ability to solve for the constraint force. Cool!

Typical analytical use

My friend Rhett Allain has a great post about one of the most famous uses of lagrange multipliers. There he talks about ice sliding off a bowl, trying to figure out when the ice leaves contact with the spherical surface of the (upturned) bowl, and also trying to figure out things about the constraint force by modeling it as a partial spring.

I have a comment there talking about how I used to teach this. I would walk students through the analytical argument, showing that you can find the angle where the constraint force (or \lambda(t)) goes to zero. But then I tried to just put the equations of motion into Mathematica to numerically integrate the solutions for x(t), y(t), and \lambda(t), and I found that you can’t start with the initial conditions that are recommended in the typical analytical approach, namely having the ice start right at the top of the bowl. Mathematica dutifully shows that the ice will just sit there if you start it there. You have to nudge it off just a little to make any interesting progress.

But really my problem with the typical analytical approach is that there’s such a small number of “perfect” problems that provide such a unique end. Just like the rest of the Lagrangian stuff I’ve done with students, I really wanted to show that this approach will work, even for hard problems that don’t have analytical results.

Mathematica break through

Unfortunately, over the last few years of toying with this in Mathematica, I’ve been stymied. What I’ve tried to do is to put the constraint Euler-Lagrange equations, the initial conditions (that meet the constraint), and the constraint equations into an NDSolve command, hoping to numerically integrate the variables and the constraint forces. However, the most common problem was this:

NDSolve::nderr: Error test failure at t == 0.013181091203435103`; unable to continue.

Arg, that’s incredibly frustrating. As far as I could ever figure, it would numerically integrate for basically one time step (note the early time when it failed) and decide that the constraint wasn’t being enforced anymore. I dug around a lot to try to figure out what was going on, but I never got any satisfaction.

But this year, as I was preparing the resources for my students for this material, I decided to take one more crack at it, and I’m glad I did, because I finally solved the problem!

I coded up a simple pendulum, giving an E-L equation for x and y, a constraint that said \sqrt{x^2+y^2}-1 had to be zero, and some initial conditions that had the pendulum up at some angle. Mathematica failed as usual, so I decided to look more carefully at the equations. I took out a sheet of paper, and I came to realize that the constraint equation is used by making x”(t) and y”(t) have a relationship, not so much using the direct relationship between x and y. So, I tried something. Instead of putting in the constraint, I defined the constraint as a function (namely g(x,y)=\sqrt{x^2+y^2}-1 and I told NDSolve that the second time derivative of g with respect to t should be zero. This gave NDSolve direct information about how x” and y” are related. And lo and behold . . . IT WORKED! Since then I’ve been using that same trick, even for problems with multiple constraints, and I’m very satisfied with the results.

Ice on a Mathematica bowl

Here’s how I can use Mathematica to do the ice on an upturned bowl:iceonblockmma

From which I can plot the constraint force:iceblockconstraintplot

It starts with a magnitude of 9.8, which is to be expected, since it needs to balance gravity near the top of the bowl. The most interesting feature of the curve is where it crosses zero. The bowl can only have a negative constraint force (it can only push, it can’t pull), so when it goes to zero, that’s when the ice leaves the surface. Using FindRoot[\lambda[t]/.sol, {t, 1.5}] we can find the time when that happens, and we can find the angle (arctan(x/y)) when that happens (~48 degrees).

Some oddities

If you look carefully at how I’m using the constraint, you’ll notice that it is never used without taking a derivative of it. That means that any constants involved in the definition of g are not used. This bothered me at first, so I looked to see what happened if I gave initial conditions that didn’t match g. In the case of the ice block, the result was that the ice stayed on a circle with whatever initial radius I gave it in the form of the initial conditions. Cool, I guess. Basically it means that you establish the functional form of the constraint to get the derivatives right (ie, the square root in the ice block case, showing the relationship between x and y), but you use initial conditions to set the  particulars.

Bead on a wire

Ok, let’s flex our muscles a little. What about a bead on an oddly shaped wire:beadonwiremma

Note that the only changes from the previous code is to change g and to change the initial conditions. Here’s the result:beadonwiremovie

Here’s a plot of the normal force as a function of time:beadonwireconstraintplot

Since the mass is set to 1, you can see there are times when the wire has to provide almost 30 g-forces to maintain its shape. Cool.

Time-dependent constraints

What about a particle on a floor that starts to tilt?tiltingplanemma

producing thistiltingplanemovie

Multiple constraints

Finally, here’s an example of a multi-pendulum, having constraints on the distance between each successive mass. When there are multiple constraints, the extension of the Euler Lagrange equation is

\frac{\partial L}{\partial y}-\frac{d}{dx}\frac{\partial L}{\partial y'}-\sum_i^N\lambda_i(t)\frac{\partial g_i}{\partial y}=0

where there are N constraints. For each one, you have to specify both g and provide for a different \lambda.

Here’s the code for a n-pendulum, constraining each length to be 1:npendulummma

which makes this animation:npendulummovie

And allows us to see the tensions necessary to pull this off:npendulumconstraintplot

Note in this plot that there’s a couple of points when some of the constraint forces change sign. At that point the strings are being asked to push instead of pull. In other words, this wouldn’t work with string. You’d have to do it with light-weight bars or something that can both push and pull.

Can you tell I’m happy I finally got this to work in Mathematica? I’m looking forward to working with my students on this on Wednesday!

Posted in mathematica, physics, teaching | Leave a comment

Rubik’s cube test development

This week I was inspired by this intriguing post by my friend Ian Beatty. He talks about what it might be like to use a test-driven development process for teaching. Here’s the short version of what I got from that: In programming, you can write a test to check all the features you want. You can do this before you actually start to build the feature, and the test will let you know when you’re done. It’ll also help you determine whether new features break old features. It was suggested that we use it last summer when we started building the physics problem database for the global physics department, but I balked because I felt it would disrupt our workflow too much. Now I’m wondering if that was a mistake. How is that connected to teaching? Well, Ian talks about how maybe we could ask students to determine what they would like to be able to do with their soon-to-come physics knowledge (that would be the test), and when they can do it, they’ve learned the material.

When I read his post, I was intrigued, but then something happened this week that helped me see his points more clearly. I solved the Rubik’s cube.

That’s right, I solved it! A few different times in my life I’ve sat down and read the manual to memorize the moves necessary to complete the puzzle, but this time I solved it. And I’m pretty proud of that. This post is about how I did it (don’t worry, no gory details) and how that might connect to Ian’s ideas.

The basic plan I used was to make sure that if I achieved anything (like a completed side or a completed row), I would then do things that I knew wouldn’t screw that up. A few things were not useful, like spinning an unsolved row, but a lot were really interesting. I found I could move a middle block from the bottom row to the middle row with the right orientation if I just moved a top corner and then moved it back, hence maintaining the top side and the top row. For the middle row, that was pretty easy, but then I had to do the bottom row, which, if I got it solved, would automatically solve the bottom side.

To solve that bottom row, I just started doing the two main things I knew wouldn’t screw up the top side and top row (moving corners and switching middles). I’d move things, and then figure out how to fix the stuff I had already “solved.” When I’d get it back to the original situation, I’d check what I’d done to the bottom row. I found I could twist corner pieces, swap middle pieces, and flip middle pieces (all in the bottom row). Then I’d just write all that down. Then I’d look at the bottom to figure out what needed to be done, hoping that the tools I’d just developed would have the flexibility to do it. And, after an evening’s worth of work, it worked!

I do need to mention one caveat about this work: My son knows how to follow the manual algorithms to solve the cube. There were many times when I would ask him to do it so that I could then see when one of my “tools” did to the bottom row. This was very valuable.

So how is this test-driven development? Well, I set the test to be “make sure the top side and top row are left unchanged.” Then I’d monkey with stuff, always checking that test to discard useless maneuvers and write down useful ones. Then, I repeated the process with the new test: “make sure the middle row stays solved.” Note that I knew what the test meant and how to check it, even before I figured out useful ways to do pass it. That’s what test-driven development seems to be all about.

Now to the teaching analogy. Here it is, baldly: The solution to the cube is some physics content you want to teach. The algorithms in the manual are like the equations we hand out. Solving it my way is like the Modeling curriculum (where students are guided to investigate the models useful in describing motion). As for test-driven development, Ian suggests that the analogy would be that “making sure the top doesn’t get screwed up” becomes:

“design self-tests that will let you know when you can predict an object’s position at any future time, given the object’s initial position, velocity, and (constant) acceleration.”

A student should be able to understand what passing that test would look like even if she doesn’t know how to go about it.

Some hanging threads I’m not sure what to do with:

  • My “solution” is much slower than my son’s, but I’m more proud of mine than he is (we’ve had that conversation). It would seem that the teaching analogy would like this. We would want our students to have pride in their self-derived approaches, even if we (secretly) know that there are more efficient ways to do the calculation.
  • What’s the analogy to the fact that my son could “reset” the cube whenever I needed it, effectively handing me a finished product on demand that I could futz with?
  • My son loves to solve the cube. He’s timing himself and he even bought a 2x2x2 to play with. I’m kind of done with it now, mostly because my approach is so slow (the bottom row, especially, takes dozens if not hundreds of moves). Hmmm, actually, it kind of sounds fun to do it again right now, but I think I’m just wondering if I can remember my own moves. Not sure what to think about that.

So what do you think? Here’s a few questions for you to help me with:

  • What do you think about test-driven development for teaching?
  • What about this analogy between the cube solution and teaching?
  • What is the analogy to my son handing me a completed cube?
  • What is the analogy to urging me to keep futzing until I find a more efficient approach?
Posted in fun, physics, physics problem db, teaching | 8 Comments