A Visual Introduction to Differentiation (using vpython)

Screen capture: Enter an x value and the program calculates the slope for the function and draws the tangent line.
Screen capture: Enter an x value and the program calculates the slope for the function and draws the tangent line.

This quick program is intended to introduce differentiation as a way of finding the slope of a line. Students know how to find the slope of a tangent line at least conceptually (by drawing). We pick a curve: in this case:

 f(x) = x^2

then enter values of x in the program to see how x, the function value and the differential compare to each other.

x f(x) f'(x)
0.5 0.25 1
1 1 2
2 2 4
3 9 6

Because it’s quick you have to change the function in the code, and enter the values for x in the python shell.

With a sin curve.
With a sin curve.

differentiation_intro_numeric.py

from visual import *

class tangent_line:
    def __init__(self):
        self.dx = 0.1
        self.line = curve()
        self.tangent_line = curve()
        self.point = sphere(radius=.25,color=color.yellow)
        self.point.visible = False
        self.label = label(pos=(-5,-8))

    '''CHANGE FUNCTION (y) HERE'''
    # the original function
    def f(self, x):
        #y = sin(x)
        y = x**2
        return y
    '''END CHANGE FUNCTION HERE'''

    def find_slope(self, x):
        sdx = .00001
        m = (self.f(x+sdx)-self.f(x))/sdx
        return round(m,3)
        
    def draw(self):
        for x in arange(xmin, xmax+self.dx, self.dx):
            self.line.append(pos=(x, self.f(x)))

    def draw_tangent(self, x):
        m = self.find_slope(x)
        y = self.f(x)
        b = y - m * x
        print "When x = ", x, " slope = ", m
        self.label.text = "point: (%1.2f, %1.2f)\nSlope: %1.2f" % (x,y,m)
        self.plot_point(x)

        #draw tangent
        self.tangent_line.visible = False
        self.tangent_line = curve(pos=[(xmin,m*xmin+b),(xmax,m*xmax+b)], color=color.yellow)
              
    def plot_point(self, x):
        self.point.visible = True
        self.point.pos = (x, self.f(x)) 

#axes
xmin = -10.
xmax = 10.
ymin = -10.
ymax = 10.
xaxis = curve(pos=[(xmin,0),(xmax,0)])
yaxis = curve(pos=[(0,ymin),(0,ymax)])

#tick marks
tic_dx = 1.0
tic_h = .5
for i in arange(xmin,xmax+tic_dx,tic_dx):
    tic = curve(pos=[(i,-0.5*tic_h),(i,0.5*tic_h)])
for i in arange(ymin,ymax+tic_dx,tic_dx):
    tic = curve(pos=[(-0.5*tic_h,i),(0.5*tic_h,i)])

#stop scene from zooming out too far when the curve is drawn
scene.autoscale = False

# draw curve
func = tangent_line()
func.draw()

# get input
while 1:
    xin = raw_input("Enter x value: ")
    func.draw_tangent(float(xin))


Chickens 911

Initial reports indicated a chicken with a broken leg; some rumors suggested the chicken had gone missing as well. These reports instigated an investigation by the Chicken Committee. They determined that the chicken was there, but something was wrong. They sent out a call for medical assistance.

X-ray of our chicken.
X-ray of our chicken.

Help came in the form of Dr. Emily Leonard from the Cherry Hills Veterinary Hospital (who happens to be a mom at our school). She took the chicken in for examination.

Based on the X-ray, there were no bones broken, so the issue must have been something else. The large egg that showed up on the radiograph suggested that the chicken could have been egg-bound, however, 20 minutes later, the chicken laid the egg.

So, the chicken is still under observation.

After the initial examination, Dr. Leonard brought the chicken back to school. It needed to be isolated and observed–which is something we now know to do in the future in any other case of injury–and the head of the Chicken Committee (the Chicken Head) made the call that the animal should go back to the hospital for the weekend.

Dr. Leonard deals mostly with pets, so she had to do quite a bit of research. “I learned a lot about chickens today,” she told me afterwards. This is a message I hope the students internalize. With the ready access to information we have today, it’s not so much about the facts you have memorized, but more about having the flexibility and ability to deal with new challenges by doing research and then applying what you learn are essential skills.

Dr. Leonard takes the chicken in for observation.
Dr. Leonard takes the chicken in for observation.

Transformations and 3D Printing

My pre-algebra class is working on transformations, so it seemed a good opportunity to try some 3d printing. I showed them how to create basic shapes (sphere, triangle, and box) and how to move them (transform) in a three-dimensional coordinate system using OpenScad.

Students create their car models using OpenScad.
Students create their car models using OpenScad.

Then we started printing them out on our 3d printer. Since it takes about an hour to print each model, we’re printing one or two per day.

The students were quite enthused. The initial OpenScad lesson took about 15 minutes, and I gave them another 55 minutes of class-time to work on them with my help. Now they’re on their own, more or less: they’ll be able to make time if they get their other math work done. A couple of them also came back into the classroom at the end of school today to work on their models.

Our first 3d printed car model.
Our first 3d printed car model.

And I think they learned a bit about transformations in space.

Toothpick Shapes’ Sequences

Toothpick shape sequences.
Toothpick shape sequences.

Using a sequence of connected shapes to introduce algebra and graphing to pre-Algebra students.

Make a geometric shape–a square perhaps–out of toothpicks. Count the sides–4 for a square. Now add another square, attached to the first. You should now have 7 toothpicks. Keep adding shapes in a line and counting toothpicks. Now you can:

  • make a table of shapes versus toothpicks,
  • write the sequence as an algebraic expression
  • graph the number of shapes versus the number of toothpicks (it should be a straight line),
  • figure out that the increment of the sequence–3 for a square–is the slope of the line.
  • show that the intercept of the line is when there are zero shapes.

Then I had my students set up a spreadsheet where they could enter the number of shapes and it would give the number of toothpicks needed. Writing a small program to do the same works is the next step.

Coding Online on the Coding Ground

For some of my students with devices like Chromebooks, it has been a little challenging finding ways for them to do coding without a simple, built-in interpreter app. One interim option that I’ve found, and like quite a bit is the TutorialsPoint Coding Ground, which has online interfaces for quite a number of languages that are great for testing small programs, including Python.

Screen capture of  Python coding at Tutorial Point's Coding Ground.
Screen capture of Python coding at Tutorial Point’s Coding Ground.

Teaching Creativity

Tina Seelig teaches creativity and innovation at Stanford. She has a new book out on the topic called Insight Out. She answered questions about the book recently and gave this answer (I’ve reformatted it into bullet points for clarity):


The model I present in Insight Out describes a series of steps from ideas to actions. Each step requires more effort than the one before.

  • Imagination requires engaging and envisioning what might be different.
  • Creativity is applying your imagination to solve a problem. This requires motivation and experimentation.
  • Innovation is applying creativity to come up with unique solutions. This requires focus and reframing. And,
  • entrepreneurship is applying innovations to bring the to the world. This requires persistence and inspiring others.

–Tina Seelig on Reddit.com.

In response to a question about testing students:

  • I don’t test my students. In fact, I tell them to never ask about their course grade. 🙂

    I want the students to be internally motivated. I tell them that I expect them to put as much work into the course as I do, and that they should “never miss an opportunity to be fabulous.” Guess what? It works! They are waiting for someone to give them this freedom to tap into their own motivation, not respond to an external motivation.