[Edu-sig] Algebra 2

michel paul mpaul213 at gmail.com
Sat Oct 4 03:22:44 CEST 2008

In our 'more motivated' Alg 2 classes we use Paul Foerster's *Algebra
Trigonometry* text.  I really like what he does, but it's clearly from
another age.  He integrates programming into the curriculum, but it's all in
BASIC.  Following is something I sent to my dept chair and colleagues that
teach the same course.  So far, no responses.

Important point - they don't even pay any attention to these problems that
involve BASIC.  They just ignore them.  However, I find it interesting that
this is the text they consider the best for our 'more motivated' students.
It has really been fascinating looking at what Foerster did regarding the
integration of programming into the curriculum.  So many of his examples
could be written as one-liners in Python.

Last night was 'Back to School Night'.  That's when we put on a little
10-minute show about our course.  I attempted to explain to parents how
computational thinking is changing how science thinks about the physical
world, how this is creating brand new inter-disciplinary majors like
computational biology, how CS is the new mathematics, that this Python stuff
is not something on top of the Algebra, it IS Algebra.

Lots of great response.  That was good.  Definitely some got it.

But it's still so weird juggling world views.


Problem 32, pg. 92:

Write a program to find the equation of a line between two points.  The
input should be the two coordinates of the two points.  The output should be
the equation in slope-intercept form.  The program should be able to handle
cases where the slope is either zero or infinite.

Here's Foerster's suggested solution in BASIC.  I'm sure you can understand
it.  Any competent math teacher should:

10 INPUT "TYPE X1, Y1"; X1, Y1
15 INPUT "TYPE X2, Y2"; X2, Y2
20 RI = Y2 - Y1
25 RU = X2 - X1
30 IF RI = 0 THEN 60
35 IF RU = 0 THEN 70
40 M = RI / RU
45 B = Y1 - M*X1
50 PRINT "Y = ";M;"X + ";B
55 GOTO 75
60 PRINT "Y = "; Y1
65 GOTO 75
70 PRINT "X = "; X1
75 END

Wow, that sure is old!  : )

Here's the same solution in Python:

x0, y0 = input('Enter x0, y0 --->')
x1, y1 = input('Enter x1, y1 --->')
rise = y1 - y0
run = x1 - x0
if rise == 0: print 'y =',  y0
elif run == 0: print 'x =',  x0
    m = rise/run
    b = y0 - m*x0
    print 'y =', m, 'x +', b

You can see the same logic, but it's a bit shorter.  That's because there's
no use of GOTO.  The elimination of GOTO was one of the important features
in the development of PASCAL, and ever since those days GOTO has been
considered bad style.  It produces crazy and cumbersome code.  Functional
organization is far superior.

You can see that the Python version is just as easy to read, or easier, than
the BASIC.  So, you can use Python in this simple procedural sort of way.
However,  Python supports various paradigms, so you can also organize things

def slope_intercept(A, B):
    x0, y0 = A
    x1, y1 = B
    rise, run = y1 - y0, x1 - x0
    if run == 0: return None, x0
    m = rise/run; b = y0 - m*x0
    return m, b

And even here, the code is longer than it needs to be.  You can cut it down

def slope_intercept(A, B):
    rise, run = A[1] - B[1], A[0] - B[0]
    if run == 0: return None, A[0]
    return rise/run, A[1] - rise/run*A[0]

And you can even cut it down more, but that's not the point.

This accomplishes the same thing as the original, just without printing the
equations.  You would then call this function to obtain the values of m and
b for printing, if that's what you wanted to do, or, you could chain this
function together with other functions to construct something more complex.
It's what functional analysis is all about.  You consider I/O stuff
decoration.  It's not the important part mathematically speaking.

Functional decomposition of tasks ---> sure sounds like Analysis to me!  :
)  Isn't it essentially the same kind of thinking?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20081003/c511a41e/attachment.htm>

More information about the Edu-sig mailing list