A number of the students in my circuits class have been having difficulty with gnuplot, but did not turn in their gnuplot scripts with their lab reports, so I could not examine the scripts to look for misunderstandings.
Debugging class lessons is much harder than debugging programs, because the computers are much more deterministic, and I can usually add extra print statements to narrow down where things are going wrong. I can’t seem to get the students who are having difficulty to show me what they can and can’t do, which makes figuring out what to explain to them difficult. There are dozens of things that they might be hung up on, and shotgun techniques where I tried to cover lots of them have not been very successful.
I have a conjecture about what is causing the students greater difficulty than I expected: scope of variables. These students have had lots of math classes, but few or no programming classes, and their math skills seem to be mainly formal manipulation. They have probably not been exposed much to the notion that the same variable may have different values in different contexts, or that variables need to be given different names if they are to be used in the same context. Math classes either always use the same variable (all derivatives with respect to x, for example) or pick new variables for each equation. It is rare for math classes to use the same function repeatedly with different parameters, and plot that function several times on the same graph. It shouldn’t be rare, but it seems to be.
I was taking scope of variables for granted in my presentations of gnuplot, since all my previous students had already been well exposed to the idea. (Well, maybe not the 5th graders I taught Scratch to, but Scratch has a simple scope notion, tying variables to sprites that are the visible objects the students are manipulating, so the problem is finessed.)
The scope rules for gnuplot are actually fairly subtle, as there are expressions that are only applicable in connection with a particular data file (like the $1 and $2 column variables), there are variables whose scope is just the “plot” or “fit” statement (like “x”), there are variables whose scope is a function definition (the parameters of the function), and there are variables whose scope is global (the parameters being fit in a “fit” statement, for example). I never explained these scope rules to the students, and the tutorials on gnuplot don’t do so either, since they are all written by programmers for whom the scope of variables is “obvious” and doesn’t need much explanation.
How will I test whether this is indeed the sticking point for the students who are having trouble? What exercises or explanations can I give them to get them to understand scope well enough? The course is not a programming course, so the usual approaches of programming courses are probably not appropriate. This pedagogical problem requires more thought—suggestions are welcome.