# The algebraic aspect of computation, or how to make them understand the usefulness and the meaning of variables

The more experience I have in teaching CS the more I become convinced that one of the most difficult ideas to grasp for (beginner) students is that of changing the inputs (if not the most difficult of all). This is so trivial and basic for us that I think we struggle to understand what's so difficult in it, at least I do. This point is what I call the algebraic aspect of computation, because, at a beginner level, it has something to do with the meaning of the dreaded x in mathematics that so many students seem to fail to understand, which is to say, the idea of variables.

In today's frustration I bring you the case of my students who, having nonetheless spent weeks copying and writing formulas in a spreadsheet, still persist in writing formulas without variables, even in cases where it's "just so obvious" that we want a result of a computation with some data: they just read the data and write a constant in the formula. I can't understand the reasoning behind this: what, in their opinion, is the usefulness of writing such a formula?

It became quite apparent observing them when doing it correctly that their only drive to use variables (cell references) is "the teacher wants it so": of course this means that they have no will whatsoever of doing it when I'm not watching.

There's even another, so to say interesting, fact: when they need a small computation for themselves, they prefer going to their backpack, take out a calculator and doing it with maybe many calculation steps and often incur some errors and doing it again maybe from the beginning because they lost the intermediate results instead of using 2 or 3 cells of the spreadsheet that they have ready in front of them. Fully oblivious of the usefulness of the tool that we have studied for months.

I know that this student behaviour is not new and I'm sure a lot of teachers have dealt with it.

The main way I (desperately) try to make them aware of all this is by saying and demonstrating with lots of examples that:

• We want it to work when we change data.
• We want to be able to use the same formula for many other cases (copy and make a long table).

But this seems highly ineffective: no connection with their inner drive, even when we beforehand state the computation that we're going to realize and see that it naturally wants to be repeated in different cases.

It struck me recently that, in asking them a question of the kind "what's the result of such and such step of our computation" (we did a thing made of 3 steps: $$f(g(h(x)))$$) they wrote "7".

Again, fully oblivious of the fact that "the step" can and will be done with differing inputs (of course we had done it and saw it on the screen and remarked it many times).

I'd like to ask if you can share your experience or intuitions about this issue, and if you have any suggestions. Especially since it's so foundational that nothing can be done in computing without this awareness, besides of course they merely copying what I do or guessing what I want from them without having any clue about the meaning.

Keep in mind that the goal for the students in these classes is to learn to use a spreadsheet and, in the minds of those who have no idea who the students are, make some data analysis. Keep in mind, moreover, that these students are not going to be scientists of any kind, the opposite: they are those that struggle a lot in understanding sentences in our own native language and make plenty of grammatical errors. We talk about 14-15 years old who have no passion for studying and are there only because school is mandatory, struggling with mathematics and logic.

On a very practical level, though, I suspect that they won't convert over to using formulas until it makes their lives significantly easier. Using lots of rows of data along with drag-downs is an easy way to accomplish this.

You can use fake data as long as you make it plausible, and then it can be fun.

Here are some statistics for 350 heavy players of "Call of Duty: Warzone", "Animal Crossings: New Horizons", and "Among Us". We need to figure out who the top 5 overall players are. First, we have to figure out an adjusted score for each game, since the scores don't compare in any obvious way across games. Then, we'll need to create rankings. Then we'll have to average performance across the three games to figure out who is best.

... it's not a perfect example, but it is something that would be basically impossible to do without using cell references.

Anything with several columns and many rows of data will do, and the more fun the data itself is, the more fun the class will have if they're not naturally motivated by the topic itself.

This isn't going to be limited to spreadsheet programming, but, more generally, to any sort of programming with mutable data. This excludes pure functional programming, but includes things like procedural programming and object-oriented programming, at least.

The main issue, I think, is that the word "variable" is used in different senses when we program and in different senses in mathematics from which the programming terminology was evolved. I think the problem is most acute with younger students who are learning programming along with algebra rather than, say, calculus.

Distinguish two cases: First is 0 = 2x * 8. Second is y = 2x * 8.

In both of these the word "variable" is often used, though "unknown" might be used in either case, though more likely the first.

But in the first case, x doesn't vary if the equation is to be true. There is only one value that makes it work. In quadratic equations there might be two values, but, still, fixed, though possibly unknown values.

In the second case we are describing the functional relationship between two (or more, in more complicated examples) variables. So, we also write the second case as f(x) = 2x * 8, naming the relationship as "f". But if you set a value for either x or y, the value(s) of the other is determined. It becomes fixed, not variable.

I think you need to get over this hurdle with students before you are likely to resolve your difficulty. With many, a logical explanation might work, but I'm not sure all are yet sufficiently sophisticated to grok it. After all, their forebrains are still developing and with it their ability to think abstractly, though it develops rather quickly starting at that age.

The other difficulty is that the notion of a "variable" is not consistent in programming. For some, it is a "box" into which you can put a "value". And the value in the box is mutable. For others, a variable assignment is a "name" that you associate with a value. The latter is the case with functional programming, of course, but the former is often used in languages that have something like C or FORTRAN as an ancestor.

I'm not certain how I can guide your students learning spreadsheets, since I don't know their backgrounds, but if they have some prior experience with C-like programming, they might have this confusion about the nature of a variable. I think, however, that you want them to think of a "variable" in the functional sense, not the "unknown" sense.

And, with unsophisticated thinkers, a set of simple examples might work, at least initially, using the "box" with a value concept (though I don't like that idea generally). But, suppose you put a 5 in "this" box? What will show up in "that" box? Suppose it is a 9 instead? Thus, starting with a simple two cell "spreadsheet" might get them thinking as you'd like. Then, develop a more sophisticated model with one or more intermediate "boxes" related to other "boxes".

The development of abstraction capabilities in the young mind can't be overlooked, however. Psychologists tell us that it won't likely be fully developed until around 25 years old. There are some (well known) exceptions, of course, but the young mind needs a more sophisticated brain, which is developing in those years.

Let me add some additional advice since you say the students aren't particularly enthusiastic about the topic, but are required to take it. Perhaps you should evaluate your overall goals for student education and ask whether spreadsheets is the best vehicle for achieving them. Perhaps some other area of CS (or even math) would better meet their needs. It might even be that the very "concrete" visual representation in a spreadsheet is actually contributing to the issue. If the goal is to increase their abstraction capabilities then there might be a better vehicle.

While recent spreadsheet programs are technically Turing Complete, I find them about as easy to program for complex tasks as I would a Turing Machine itself. I've known some who can do that, but I don't find it easy to conceptualize in that way.