Facebook
Edutopia on Facebook
Twitter
Edutopia on Twitter
Google+
Edutopia on Google+
Pinterest
Edutopia on Pinterest Follow Me on Pinterest
WHAT WORKS IN EDUCATION The George Lucas Educational Foundation
Subscribe to RSS

Programming & Simulation: Real Technical Skills for Today's Student

Manan Shah, PhD

Mathematician, Consultant, Owner of Think. Plan. Do. LLC.

Technology is here to stay. There are two main ways of interfacing with technology: passively as a user and actively as a developer. Today's technical problems are very complicated -- they cannot all be solved in theory on a whiteboard or exhaustively via computation. The use of simulation methods to obtain a "solution" to the problem at hand is not uncommon in industry. The purpose of this post is to provide broadly a "why" and "how to" for introducing simulation methodologies into high school math and programming courses. While the subject matter is technically deep, the concepts are well within the grasp of high school students -- and possibly younger students.

A Quality Control Example

In practically every industry, there is heavy pressure to cost-effectively produce high quality products. The quality control processes in place can vary depending on the rules and regulations, the business impact of a faulty product making it to market, the quantity of the product being produced, etc.

So let's say that we run a widget-making business. Our widgets are complex and require ten independent components to be fitted together for the widget to work. If one component is faulty, the widget won't work. Fortunately, we can test each component with 100% accuracy before assembling it into the widget. We build widgets on demand and thus we are not concerned with excess capacity. Each component, inclusive of all expenses, costs one dollar to manufacture. So at minimum, each widget costs us ten dollars. We sell each widget for twelve dollars.

If we manufacture each component with 99% efficiency, are we making or losing money on our widgets?

If we can simulate producing, say, one million widgets with the rules stated above, we could get an idea for the average cost, among other things.

Here is what code (with overly verbose variable names) could look like. This is written in a programming language called Python.

 

Credit: Manan Shah

 

And here is what happens if we run a few instances of it. As we can see, it looks like we use ten components to make a widget.

 

Credit: Manan Shah

 

But! We have computing resources at our disposal. So let's see what happens to our average cost if we make one million widgets.

And voila, it's as easy as this:

 

Credit: Manan Shah

 

As we can see, it looks like our average cost is $10.10 per widget. Which means that each component really costs us on average $1.01. We certainly are making money. (What's our profit margin?)

What would happen to our cost if we could only test our widget once we had all ten components together? And since we've built the widget, if it is faulty we have to toss the entire widget. Are we still profitable? I will leave this as an exercise for the reader.

The creative instructor can also add several other exercises that build on this. What happens to the cost of a widget if our efficiency goes to, say, 98%? Also, would the cost of producing a component decrease if our efficiency decreased? What are the business ethics of this? The instructor can also discuss topics like statistical error (we probably can't have a 100% effective test), independence of events, standard deviation/standard error, etc.

Other Exercises to Consider

In the previous section, we saw how a simple and graspable problem of quality control is rich in lessons about probability and programming. Additionally, while a student may have difficulty solving this problem on paper, it can be readily tackled via a few short programs. Here are some exercises that the instructor may want to consider:

  • The Travel Industry Problem: What is the cost/benefit of overbooking for airlines and hotels?
  • The News Vendor Problem: How many newspapers should the news vendor print?
  • The Traveling Salesman Problem: What is the most cost-efficient tour of cities? (This can be a nice classroom competition!)

 

Getting Started

I took programming in high school and as an undergraduate. I didn't understand programming one bit. Then at my first post-bachelor's degree job, I wanted to automate some spreadsheet task, and suddenly, for reasons unknown to me, programming was not difficult. I've never looked back since, and I continue to learn about the new technologies out there. If it weren't for that exposure early on, the information would never have marinated in my brain, and the time it would have taken me to learn how to program would have been much greater -- time that my job probably could not have afforded.

If you're interested in pursuing activities like these, here are some classroom tips:

  • It's not synchronized swimming. Not everyone is going to learn at the same pace.
  • Some students will ask to see many examples before they feel that they've mastered the subject.
  • Some students will feel comfortable editing code at first before writing from scratch on their own.
  • Have students comment, line by line, on small snippets of code that you have written.
  • Some students may simply not understand. Instead of expecting that they will learn how to program through a specific programming language, try to engage them in algorithmic and procedural thinking outside of mathematics and programming.

Comments (5)Sign in or register to postSubscribe to comments via RSS

vinoth's picture

Wow !! but i don't know how to use the python programming language, could you suggest any other language that would be helpful in a similar way..... kindly reply!!!!

Manan Shah, PhD's picture
Manan Shah, PhD
Mathematician, Consultant, Owner of Think. Plan. Do. LLC.
Blogger 2014

There are plenty out there. In my opinion, Python and Ruby are pretty easy to pick up. C++ and Java are popular as well, but may need a little more up-front investment on your part to understand what's going on.

You can even do some of these exercises in spreadsheet software.

Does this help?

Amy Zimmer's picture
Amy Zimmer
High School Math Teacher, Sebastopol, California

So this type of problem would be taught within Algebra 2 or within a programming class?

Manan Shah, PhD's picture
Manan Shah, PhD
Mathematician, Consultant, Owner of Think. Plan. Do. LLC.
Blogger 2014

This can certainly be done in a programming class.

What I wanted to get at was to weave programming into math classes. I've seen some Algebra 2 syllabi mention that elementary probability and statistics will be covered and for those courses this type of exercise would be appropriate.

The example given in the article is just a motivating example to highlight, among other things, that a problem normally reserved for an undergraduate or advanced high school probability / statistics class, is conceptually graspable and 'solvable' via programming methods. The students don't need to formally know that they are working with a binomial or a geometric distribution. They just have to conceptually understand what a probabilistic success is.

There are plenty of other math / programming exercises that can be done in an Algebra 2 course. For example, the application of the rational root theorem to find possible rational solutions to an n-degree polynomial with rational coefficients is tedious to work out by hand and, in my honest and humble opinion, is of little conceptual value to students. Nevertheless, since it seems to be a part of the course, it would make for a good (and challenging!) programming exercise. The instructor can "build" up to this, by first having students write a program to factor integers (don't worry about having a sophisticated factorization program).

Another example for an Algebra 2 course is to have students write a program to handle complex arithmetic. While Python has this built-in via the complex type, it is still a nice exercise for students to do.

For example, to add (3 + 4i) + (-2 + 5i), here is a simple method:
>>> def complexadd(comp1, comp2):
##comp1 is a list of two elements, the first element is the real part
##comp2 is like comp1
return [comp1[0] + comp2[0], comp1[1] + comp2[1]]

>>> complexadd([3,4],[-2,5])
[1, 9]

I hope this helps!

Sign in and Join the Discussion! Not a member? Register to join the discussion.