Re: [Edu-sig] Programming in High School

2008-12-10 Thread David MacQuigg
At 02:37 PM 12/8/2008 -0500, Vern Ceder wrote:

... here are the reasons I see that more
schools don't offer programming:

1) Lack of qualified staff. Sadly a graduate with a teaching certificate
(as required by the state) usually doesn't have anything like the
background to teach programming, let alone do the sorts of things that
Kirby has experimented with.

What we need then, is not programming teachers, but teachers who are 
enthusiastic about technology, and use programming as a tool.  I would think 
any teacher of math or science would have no difficulty using Python and 
integrating it into their teaching.  Don't teach it as a separate subject, but 
introduce each new statement as it is needed.  For-loops, as an example, could 
be introduced as a tool to plot functions.  The, when the students are 
comfortable with that (and if there is time), show them a whole new and more 
general way of looking at for-loops (for item in collection).

I remember taking a class in typing.  There was a lot of stuff on proper 
etiquette and formatting of business letters, and emphasis on speed and 
accuracy, but it was one of the most valuable classes I ever took.  Do they 
still have something like that, maybe a business skills class?

Python has a special role here, in that it doesn't require a big, focused 
effort, as would Java.

2) Numbers - at my school, 6-10 kids in AP Programming is considered a
good year. In the public schools around town, in a short-sighted drive
for efficiency, (but see item 1 above also) administration routinely
kills any elective that can't get 3 times that.

3) The whole integration trend in tech in education - 15 years ago it
was assumed that as technology became ubiquitous we wouldn't have to
teach it, any more than you need to know about electricity to turn on a
light. Of course, that analogy was bogus on both ends, but schools have
moved in that direction anyway, killing what little programming they did
have. Only now (and only very slowly) are they realizing that their
students are the poorer for it.

This fits with Paul's theme that we don't need programmers because it will all 
be done for us, or Guido's that only the best students should study 
programming.  I was once asked by a shop teacher why I am still doing 
programming.  Aren't all the programs already written?

We need lots of examples where programming is useful to non-programmers.  I 
already mentioned the real estate agent needing to digest some data from the 
property appraisers office.  For the shop teacher: How about a homeowner 
wanting to lay tiles, avoid wastage, and slivers that look bad along the edge.  
If you know Python, it is quicker to write a little program than find one, 
purchase and install it, read the manual, struggle with a bunch of stuff you 
don't really need, and maybe not get what you want in the end.  I can think of 
lots of examples in engineering, but they are not ordinary problems that would 
seem relevant to high school students.  What we need is a collection of 
relevant problems, easily solved with a quickie program.

These factors (and others of course) combined with the many layers of
bureaucracy create a negative feedback loop that is next to impossible
for students, teachers or even parents to beat. In fact, I've talked to
state education officials that nearly despair of making any headway in
some of our schools.

I would think the Federal government could play a positive role in encouraging 
modernization of our curricula.  Are there any proposals for the new 
administration?  I'm thinking of an effort similar to what the Internet 
Security Alliance is now making in the area of infrastructure for a more secure 
computing environment.  There is a whole new enthusiasm replacing the despair 
of the last few years.


___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Programming in High School

2008-12-10 Thread David MacQuigg

We need lots of examples where programming is useful to non-programmers.  I 
already mentioned the real estate agent needing to digest some data from the 
property appraisers office.  For the shop teacher: How about a homeowner 
wanting to lay tiles, avoid wastage, and slivers that look bad along the edge. 
 If you know Python, it is quicker to write a little program than find one, 
purchase and install it, read the manual, struggle with a bunch of stuff you 
don't really need, and maybe not get what you want in the end.  I can think of 
lots of examples in engineering, but they are not ordinary problems that would 
seem relevant to high school students.  What we need is a collection of 
relevant problems, easily solved with a quickie program.

Here is another suggestion:  How about a program to predict stock prices?  
We'll need maybe 1000 traders, each responding to a dozen random external 
events.  That will gives us a simple random walk around the mean.  Now let's 
make it more interesting.  Give each trader a herding tendency making it 
follow more closely what its nearest neighbors are doing.  Turn up the herding 
coefficient and watch how it makes the market more erratic, ultimately turning 
random walk into boom and bust.


___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Programming in High School

2008-12-10 Thread Winston Wolff
I agree that finding relevant problems that are easily solved with a  
quickie program is hard to find. One idea I've been toying with at  
Stratolab from our programming coures is having a programming game to  
artificially create interesting quickie programs.


How about Robot Wars of the past, but you are writing your robot's  
logic in Python? Each student writes a little program, drops them into  
a folder on the network.  The teacher's computer is running an Arena /  
Simulation. It checks the folder and loads any programs there and  
starts the simulation. Robots that die get deleted from the folder so  
students have to rewrite it and drop new copies in to see if they  
survive.


-Winston

On Dec 10, 2008, at 12:12 PM, Warren Sande wrote:




David MacQuigg wrote:
We need lots of examples where programming is useful to non- 
programmers.  I already mentioned the real estate agent
 needing to digest some data from the property appraisers office.   
For the shop teacher: How about a homeowner wanting
 to lay tiles, avoid wastage, and slivers that look bad along the  
edge.  If you know Python, it is quicker to write a little
 program than find one, purchase and install it, read the manual,  
struggle with a bunch of stuff you don't really need,
 and maybe not get what you want in the end.  I can think of lots  
of examples in engineering, but they are not ordinary
 problems that would seem relevant to high school students.  What  
we need is a collection of relevant problems,

 easily solved with a quickie program.

These are not so easy to find.  For many of these types of problems,  
creating a spreadsheet is more efficient that writing a program.   
(Why re-invent the wheel?)  One could argue that having more people  
know how to use Excel is a good thing and goes part of the way to  
having a population that's more savvy at computers/math/problem- 
solving.  That's another discussion.


But the criteria of relevant problems, easily solved with a quickie  
program is tough to meet.  Not much gets through that filter.   
Problems that are relevant and complicated enough to be interesting  
usually require a moderately complex program to solve them.  The non- 
programmer has to make at least some investment in learning the  
basics (variables, loops, control structures, operators, lists, I/O)  
before taking on even the simplest problem-solving using a program.   
So we need to convince people that it's:  a) not that hard   and
b) worth it.



Warren Sande.

___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig


Winston Wolff
Stratolab - Computer Courses for Teens and Kids
(646) 827-2242 - http://stratolab.com

___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Programming in High School

2008-12-10 Thread michel paul

 I would think any teacher of math or science would have no difficulty using
 Python and integrating it into their teaching.  Don't teach it as a separate
 subject, but introduce each new statement as it is needed.


Right.  That's the strategy I thought would be most practical working within
the constraints of our math curriculum.  I decided against doing something
like a Python intro at the beginning of the semester, as student schedules
are in flux for the first couple of weeks.  The pace of a typical math
course makes it quite possible to introduce little bits of Python here and
there.  The only problem has been resistance on the part of students who
didn't see why they had to spend time on this when their friends in other
classes didn't.  That, or they were concerned that this would 'confuse'
them, and they were worried about their grade.  Silly stuff.  And then this
silly stuff would require my having to explain to various people about what
this is all about.  However, a lot of that has faded, and some students are
even asking if we could do more Python.  So that's encouraging.

There is a big contrast between doing math the traditional way, solving
equations by manipulating symbols in some boolean assertion to isolate a
variable, vs. thinking computationally - creating sets of functions to model
concepts.  Introducing this stuff eventually requires rethinking the whole
curriculum.  But one step at a time.

- Michel

On Wed, Dec 10, 2008 at 7:35 AM, David MacQuigg [EMAIL PROTECTED]wrote:

 At 02:37 PM 12/8/2008 -0500, Vern Ceder wrote:

 ... here are the reasons I see that more
 schools don't offer programming:
 
 1) Lack of qualified staff. Sadly a graduate with a teaching certificate
 (as required by the state) usually doesn't have anything like the
 background to teach programming, let alone do the sorts of things that
 Kirby has experimented with.

 What we need then, is not programming teachers, but teachers who are
 enthusiastic about technology, and use programming as a tool.  I would think
 any teacher of math or science would have no difficulty using Python and
 integrating it into their teaching.  Don't teach it as a separate subject,
 but introduce each new statement as it is needed.  For-loops, as an example,
 could be introduced as a tool to plot functions.  The, when the students are
 comfortable with that (and if there is time), show them a whole new and more
 general way of looking at for-loops (for item in collection).

 I remember taking a class in typing.  There was a lot of stuff on proper
 etiquette and formatting of business letters, and emphasis on speed and
 accuracy, but it was one of the most valuable classes I ever took.  Do they
 still have something like that, maybe a business skills class?

 Python has a special role here, in that it doesn't require a big, focused
 effort, as would Java.

 2) Numbers - at my school, 6-10 kids in AP Programming is considered a
 good year. In the public schools around town, in a short-sighted drive
 for efficiency, (but see item 1 above also) administration routinely
 kills any elective that can't get 3 times that.
 
 3) The whole integration trend in tech in education - 15 years ago it
 was assumed that as technology became ubiquitous we wouldn't have to
 teach it, any more than you need to know about electricity to turn on a
 light. Of course, that analogy was bogus on both ends, but schools have
 moved in that direction anyway, killing what little programming they did
 have. Only now (and only very slowly) are they realizing that their
 students are the poorer for it.

 This fits with Paul's theme that we don't need programmers because it will
 all be done for us, or Guido's that only the best students should study
 programming.  I was once asked by a shop teacher why I am still doing
 programming.  Aren't all the programs already written?

 We need lots of examples where programming is useful to non-programmers.  I
 already mentioned the real estate agent needing to digest some data from the
 property appraisers office.  For the shop teacher: How about a homeowner
 wanting to lay tiles, avoid wastage, and slivers that look bad along the
 edge.  If you know Python, it is quicker to write a little program than find
 one, purchase and install it, read the manual, struggle with a bunch of
 stuff you don't really need, and maybe not get what you want in the end.  I
 can think of lots of examples in engineering, but they are not ordinary
 problems that would seem relevant to high school students.  What we need is
 a collection of relevant problems, easily solved with a quickie program.

 These factors (and others of course) combined with the many layers of
 bureaucracy create a negative feedback loop that is next to impossible
 for students, teachers or even parents to beat. In fact, I've talked to
 state education officials that nearly despair of making any headway in
 some of our schools.

 I would think the Federal government could play 

Re: [Edu-sig] Programming in High School

2008-12-10 Thread kirby urner
2008/12/10 michel paul [EMAIL PROTECTED]:

 SNIP 

 There is a big contrast between doing math the traditional way, solving
 equations by manipulating symbols in some boolean assertion to isolate a
 variable, vs. thinking computationally - creating sets of functions to model
 concepts.  Introducing this stuff eventually requires rethinking the whole
 curriculum.  But one step at a time.

 - Michel

Yes Michel, but let's remember schoolish math isn't necessarily what
the pros are doing to earn a living, with Mathematica, MathCad or
whatever.  Lots of degree holders in mathdom spend half their time
talking to coders with humanities degrees like me, explaining what
outputs from what inputs, in terms of algorithms per Knuth, i.e. the
stuff you learn in K-12 isn't computer poor because of anything to
do with real world mathematics in practice.

The way I might do it in Portland (write ups in blogs) is take what
we'd consider an advanced, college level theorem, such as Fermat's
Little (not Last), and use Python to verify what it asserts, not the
same thing as proving.  What I say often @ Math Forum is something
like:  before you prove a theorem, you need to know what it means,
i.e. you need to care.  Having field applications helps motivate
caring.  We might not ever get to the proof in this class (heresy!)
as these are underclassmen looking to understand RSA, haven't
chosen to become mathematicians.

What's so cool about Python is pow(2, 22, 23) is so easy to write
and explain (no import required), whereas on a calculator you get
digit overflow most the time, because of the overly small LCDs,
hamster-brained programs (not open source).

Per my Chicago talk, OSCONs before it, Texas Instruments is our
only real competition in this picture in a business case sense,
though fear of snakes (per 'Snakes on a Plane') is probably the
biggest psychological barrier.  North Americans are especially
superstitious about snakes, owing to their making Eve do something
bad in the Bible (what was it again?).  Ruby has an edge in that
sense (less charged) -- but then we have a Flying Circus, which
helps a lot.

We basically invite kids to fill in the form:  pow(2, prime - 1, prime)
and verify that they always get 1 for an answer.  Then comes the
tricky part:  does that mean that if pow(2, n-1, n) returns 1, that
n must be prime?  Having verified it's true for like a gazillion primes,
the overly casual thinker might say sure!.  But of course this is
a logical pitfall.  if a then b does not support b therefore a.
That's where we talk about Carmichael numbers, look them up
on the web (OEIS).

Fermat's Little is a special case of Euler's more general one about
totients (lots of fun Python), in turn critical for getting RSA to work
(per Knuth).  All before college, looks good on your application
(that you went to this cutting edge Quaker school or whatever).

Kirby
4D
___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Programming in High School

2008-12-10 Thread Edward Cherlin
On Mon, Dec 8, 2008 at 6:57 AM, David MacQuigg [EMAIL PROTECTED] wrote:
 Kirby,

 This is very well written appeal, but in this mailing list, you may be 
 preaching to the choir.  What I would like to see is a discussion of *why* 
 there is not more teaching of programming in high school.  I can't seem to 
 get an answer from the few high-school teachers and students I have asked. I 
 suspect it has something to do with requiring all kids to have their own 
 computers, not wanting the rich to have an advantage over the poor, etc.  
 I've thought about teaching high school myself, but the bureaucracy seems 
 overwhelming.

It is a much more systemic problem than that. I put a lot of blame on
the anti-intellectual forces in society that want education dumbed
down so that they can lie to their own children, and then to the
general public that grows up on this pablum. The fundamental problem
is the insistence on factory-style efficiency in education, a trend
started by Prussia in the 18th century. The result is that schools
nearly always teach only material for which there is an official right
answer, while in real life, whether business, government, the arts, or
politics, all of the interesting questions have no right answer.

The education of teachers was also radically dumbed-down in the
Prussian system. Teachers were expected to know no more than was in
the textbooks they would teach from, except at the highest levels in
research universities. In this view of society, those who needed to
deal with the unanswered questions on a daily basis (other than
scientists and engineers) were to be children of the elite class who
could afford to send them to private schools to receive an entirely
different sort of education. The sort of exceedingly unpleasant system
for generating leaders within an Empire that Kipling described in
Stalky  Co. http://www.geocities.com/Athens/Academy/6422/rev0882.html

The Prussian system was put in place by a King who wanted a compliant
public that would make no attempt to interfere in his planning of the
next war, and by a right-wing Calvinist church movement that the King
preferred over the more liberal-minded Lutherans. _All_ of the
Imperial powers and the churches and business interests that supported
them supported this system for public education at home and abroad.
Japan and the State Shinto authorities particularly loved the German
educational system. Plus ça change, plus ç'est la même chose.

To come back to programming, what we have had since the introduction
of personal computers in the 1970s has not been programming but
so-called computer literacy, in which children might get as much as
an hour or two a week in the computer lab. As an immediate
consequence, nothing they learned about computers, or from using
computers, could have any relevance to the curriculum. It is only now,
with the advent of one-to-one computing, that we can even think of
addressing this problem.

If we compare the computer literacy approach to programming with the
actual idea of literacy, we see that what we have been doing is
pretending to think we are teaching reading and writing if we have one
room in a school with 30 pencils and pads of paper, but no library,
and we let kids practice handwriting for as much as an hour a week.
But not at home, or in public, no of course not. But what would
schools do with programming in a one-to-one computing environment?
Well, I predict that if left to themselves, they would mess it up as
badly as we mess up literacy, or math and science, or indeed any
subject today. We only let students have access to an utterly boring
and stultifying version. It is just like exposing children to killed
or attenuated viruses in order to make them immune to those viral
diseases. Our schoolbooks contain nothing like the versions of any of
these fields that made the practitioners fall in love with the
possibilities enough to put forth the effort to master some part of
it, and our schools make far too many children immune to learning
anything ever again.

Earth Treasury has just recently, actually just yesterday, come to the
conclusion that we are ready to rethink the notion of a textbook, and
to rework the curriculum from top to bottom, in order to integrate
Free Software into every aspect of every subject. Some things in
education actually take place in the material world, of course,
including gym, manual training, art, and music. Even there, the
computer is an important tool. Think of all of the computerized
athletic training and analysis systems of Olympic athletes and the
pros; or of CAD/CAM; or digital art and electronic music.

The occasion yesterday was the Program for the Future conference at
the Tech Museum (San Jose CA), Adobe Systems, and Stanford, and the
celebration of the 40th anniversary of Doug Engelbart's Mother of All
Demos (look it up and watch the video), which laid the foundations for
all modern user interfaces, and much else in software engineering,
innovation 

Re: [Edu-sig] Programming in High School

2008-12-10 Thread kirby urner
On Wed, Dec 10, 2008 at 1:57 PM, Edward Cherlin [EMAIL PROTECTED] wrote:

 SNIP 

 The occasion yesterday was the Program for the Future conference at
 the Tech Museum (San Jose CA), Adobe Systems, and Stanford, and the
 celebration of the 40th anniversary of Doug Engelbart's Mother of All
 Demos (look it up and watch the video), which laid the foundations for
 all modern user interfaces, and much else in software engineering,
 innovation support, and more. We have come nowhere near realizing it
 all. I talked with Doug, with Alan Kay (of Dynabook, Smalltalk and GUI
 fame) of Viewpoints Research Institute and with Mike Linksvayer from
 Creative Commons (look up their cc:Learn project) yesterday, and with
 Sugar Labs, FLOSS Manuals, and Open Learning Exchange before that, and
 they are all ready to talk about how we can do all this. So let me
 know about any subject and age range you want to work on.

This seemed an eloquent essay Edward, love poking fun at those
Prussians, aka control freaks par excellance.  Makes me start humming
bars from Pink Floyd (hey, teacher...) just thinking about it.

Safe to say, much time has elapsed and for all the whining we hear
from constructivists, as if their way had never been tried, it has
been, with mixed results, which is to say we've had many success
stories, generations of geek reared on Dr. Spock, Vulcan Spock and
beyond, given microscopes, computers, free reign, lots of adulation in
school, quite the opposite of the Prussian philosophy.

Result:  Apple Computer, Silicon Valley, Silicon Forest i.e.,
thanks to the long-ago demise of top-down authoritarian thinking in
some circles, we have some thriving subcultures on planet Earth where
the mind runs free, bringing good things to life (GE slogan), making
the world a better place etc. etc.

The question is:  how to spread the love?  My approach is to leverage
local strengths, Portland's good ats, and that's a pretty long list,
including cartoon-making, music, comedy and, yes, teaching Python at a
level most cities can't match, thanks to me, but also thanks to a lot
of people, many unsung (so far).  Tim Bauman comes to mind (one of my
proteges, aka Ki Master George).  Jason certainly (a fine teacher of
SQL Alchemy and like that).  Allison Randall, Damien Conway, R0ml,
Ravencroft...  a lot of us, right here on this list.

I'm not saying all of these celebs live in PDX, just that there's
reason to hope that we're not just now, at long last, emerging from
the dark ages, as if Prussia had just folded yesterday.  No, we've
been enjoying the fresh air for a few generations now, and are ready
to bring it on as one recent president put it (meaning something
else maybe, always hard to decipher that guy, study Dan Quayle as a
primer maybe?).

Guido's CP4E was a continuation of a noble tradition, Alan Kay in the
lineage, or Kenneth Iverson in my case (I encountered Alan much later,
long after I'd fallen in love with APL at Princeton, Alan then in his
kill Smalltalk slayer chapter (more in this archive))

I think the right approach is to think in terms of an svn tree, i.e. a
trunk with many branches.  We're *not* all converging to the same page
(this won't be Prussia again, don't worry).

Some of us, like me, will probably use J quite a bit, because of the
APL heritage.  Others will use Scheme / LISP, that Big Lambda family
(Python's is little lambda).

It's not about finding the one right way to do it (Prussian fallacy)
but rather one of encouraging local faculties to seize control of
their own destinies and not wait for big publishers to show them how
it's done.  We already have Cut the Knot, Mathworld, gazillions of
math-oriented YouTubes.  We're awash in relevant curriculum materials.

The last time I said anything about Kusasa (which was quite awhile
ago), it was to suggest there was no need for any new curriculum
writing whatsoever, just people need time to catch up, process what's
already out there. Of course that's a pretty stupid thing to say to a
bevy of curriculum writers rarin' to go, but I think you see my point
anyway.

There's a documentary on Britney Spears on my TV at the moment, gotta
run.  She's one of those music millennium geeks I really appreciate
these days, love how she figures into our circus, no dummy that
gl.  http://mybizmo.blogspot.com/2008/10/pythonic-math.html

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] Programming in High School

2008-12-10 Thread Gregor Lingl



Daniel Ajoy schrieb:

But the criteria of relevant problems, easily solved with a quickie
program is tough to meet.  
  

...

And another point is that some problems cannot be solved using algebra or trig. 
I believe this is one:

http://neoparaiso.com/logo/problema-triangulos.html

It asks the student to determine the values of the segments a and b.
This is a nice problem, which could also find an easy solution in 
Python, not only in Logo, of course ;-)

Like the on attached one, for instance.

I'd only like to add a few remarks to the problem discussed in this 
thread - which I also know very well as a high school teacher in Vienna, 
Austria.


(1) One root of the problem seems to be that whatever relevant problem 
we pose, there are *a lot* of different adequate tools to approach it in 
these modern times and it is by no means clear that programming is the 
'natural' approach. See for instance


http://www.rg16.at/~glingl/triangle/

for a different solution to Daniel's problem.

(2) To profit from beeing able to program needs continuous practice. So 
as a teacher of a math class you had to convince *all* of your students 
to do it continually.


(3) This - at least here in Austria - seems to be impossible as long as 
programming is not part of the official math curriculum (like for 
instance the appropriate use of a pocket calculator). Even core math is 
not done by *all* students on their own free will, because they enjoy 
it, or they are interested in it, but by some of them often only because 
they *need* it for their gradutation. And I suppose that programming 
will  never be part of the standard curriculum, even if only because 
only a small part of the maths teachers are proficient in programming. 
So they naturally would oppose such a change.


(4) Moreover it seems to me, that even in the area of computer science 
or computer technology the part which is occupied by programming is 
getting smaller. 25 years ago, if you wanted to do some interesting 
things with a computer, you *had* to be able to program, while nowadays 
there are so many interesting things you can do without programming. For 
instance what do you think, which part of the people working in the 
comuter game industry are programmers? I suppose, this trend also 
diminishes the young people's interest in programming (as well as the 
school authorities interest in putting programming into the mainstream 
curricula.)


(5) Despite all of this I'd also like to contribute a problem, I 
stumbled over yersterday, incidentally. It might not be 'relevant' but 
it's also one that most probably couldn't be solved without computers 
and which without doubt has the potential to stimulate the student's 
interest in math as well as computing:


Christian Goldbach (1690-1783), stated several number theoretical 
conjectures, among them the famous Goldbach conjecture, concerning the 
set of even numbers  2.


An other (similar) one is the following: every odd positive integer 
could be written in the form p + 2*a**2, where p is a prime (or 1, then 
considered a prime) and a =0 is an integer. Example: 23 = 5 + 2*3**2 
(to use Python notation). Euler checked this conjecture for odd numbers 
up to 2500 and he didn't find a counter example. Only a century later 
two counter examples were found in the range below 1.  What are 
these two numbers?
The curious thing is, that to this day these two numbers remain the only 
ones found.


Regards

Gregor





Daniel

___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig


  
# Daniel Ajoys triangle problem
# from Edusig, 10. 12. 2008

from turtle import *

def triangle(wx):
penup(); home(); pendown()
forward(130)
left(180-38)
forward(wx)
setheading(180 + towards(0,0))
forward(70)
right(180-101)
forward(88)
#stamp()
return ycor()

setup(500,250)
mode(world)
reset()
fd(250)

triangle(80)
triangle(50)

# no-frills graphical solution
# of course one could play around with colors etc...

wx1 = 80
wx2 = 50

epsilon = 0.1

while True:
wx = (wx1 + wx2)/2.0
y = triangle(wx)
if abs(y)  epsilon:
print Solution:, wx
break
if y  0:
wx1 = wx
else:
wx2 = wx


setworldcoordinates(190, -2.5, 200, 2.5)
write(str(pos())+ for wx =  + str(wx))




___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig


[Edu-sig] computer algebra

2008-12-10 Thread kirby urner
So I've been yakking with Ian (tizard.stanford.edu) re the new
fractions.py, installed in Standard Library per 2.6, saw it demoed at
a recent user group meeting (PPUG).

Python's __div__ is similar to Mathematica's computer algebra notion
of division in that you're free to divide any type by any type,
providing this makes any algebraic sense, using a kind of liberal duck
typing.

What I mean by that is __div__ by itself doesn't pre-specify anything,
so if there's a meaningful way to deploy the division operator between
arguments A, B, then go ahead and do it, write you code accordingly.

In Java, we could write __div__ in all different ways depending on
valid type permutations (not that Java has operator overloading, just
stricter typing at write time means you've gotta post guards at the
gate in your methods).  Python, with late binding, duck typing, won't
post guards, but you'll still need to write algorithms capable of
sorting out the possibilities.  Maybe the user throws you a matrix?
Has an inverse.  OK, so __div__ makes some sense...

fractions.py in contrast, implements the narrow Q type, the rational
number, defined as p / q where p, q are members of the set integers.

One could imagine a Fraction class that eats two complex numbers, or
two Decimals.  Computer algebra attaches meaning here, as in both sets
we're able to define a multiplicative identity such that A / B means A
* B**(-1) i.e. A * pow(B, -1) i.e. A * (1/B).

So the results of this operation, Fraction(A, B), might be some object
holding the Decimal or Complex result.  In generic algebra,
everything's a duck, although conversion between types is possible
(yes, that sounds nonsensical).

fractions.Fraction, on the other hand, barfs on anything but integers,
isn't trying to be all divisions to all possible types, isn't
pretending this is Mathematica or a generic CAS.

Note that I'm not criticizing fractions.py in any way, am so far quite
happy with it.  I'm simply drawing attention to some fine points.

Related:

When I went to all the trouble to compose two functions, f and g,
using __mul__, I'd get comments like:  but the open oh (another
symbol) is the composition operator i.e. you're only using *
because ASCII doesn't include the 'open oh'.

However, I was making a different point:  that in group theory math
texts, we're proud to use regular multiplication and division
operators for such operations as compositions of functions because
we're thinking __mul__ and __div__ have that generic meaning -- we
neither need, nor want, the proliferation of symbols the open oh
people think we must need.

Note that by open oh I'm not talking about big oh, a different
notation that I don't think is redundant, agree with Knuth that if
your calculus book doesn't include it, you're probably in one of those
computer illiterate schools (ETS slave, whatever).

Kirby
___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] computer algebra

2008-12-10 Thread Guido van Rossum
On Wed, Dec 10, 2008 at 6:47 PM, kirby urner [EMAIL PROTECTED] wrote:
 So I've been yakking with Ian (tizard.stanford.edu) re the new
 fractions.py, installed in Standard Library per 2.6, saw it demoed at
 a recent user group meeting (PPUG).

 Python's __div__ is similar to Mathematica's computer algebra notion
 of division in that you're free to divide any type by any type,
 providing this makes any algebraic sense, using a kind of liberal duck
 typing.

 What I mean by that is __div__ by itself doesn't pre-specify anything,
 so if there's a meaningful way to deploy the division operator between
 arguments A, B, then go ahead and do it, write you code accordingly.

Or unmeaningful! Unlike (I presume) Mathematica, Python doesn't mind
if you define a/b as multiplication. Your users might mind though. :-)

 In Java, we could write __div__ in all different ways depending on
 valid type permutations (not that Java has operator overloading, just
 stricter typing at write time means you've gotta post guards at the
 gate in your methods).  Python, with late binding, duck typing, won't
 post guards, but you'll still need to write algorithms capable of
 sorting out the possibilities.  Maybe the user throws you a matrix?
 Has an inverse.  OK, so __div__ makes some sense...

 fractions.py in contrast, implements the narrow Q type, the rational
 number, defined as p / q where p, q are members of the set integers.

 One could imagine a Fraction class that eats two complex numbers, or
 two Decimals.  Computer algebra attaches meaning here, as in both sets
 we're able to define a multiplicative identity such that A / B means A
 * B**(-1) i.e. A * pow(B, -1) i.e. A * (1/B).

It's not so easy though. The specific purpose of the Fraction class is
to always reduce the fraction to a canonical representation using the
GCD algorithm (e.g. 15/12 becomes 5/4), which only applies to
integers.

 So the results of this operation, Fraction(A, B), might be some object
 holding the Decimal or Complex result.  In generic algebra,
 everything's a duck, although conversion between types is possible
 (yes, that sounds nonsensical).

 fractions.Fraction, on the other hand, barfs on anything but integers,
 isn't trying to be all divisions to all possible types, isn't
 pretending this is Mathematica or a generic CAS.

Fortunately Python supports a way of overloading binary operators
where it is sufficient if *one* of the operands knows how to deal with
the other. So Fraction(3, 4) * 2j happily returns 1.5j. You don't have
to teach Fraction about Matrix if you can teach Matrix about Fraction.

 Note that I'm not criticizing fractions.py in any way, am so far quite
 happy with it.  I'm simply drawing attention to some fine points.

 Related:

 When I went to all the trouble to compose two functions, f and g,
 using __mul__, I'd get comments like:  but the open oh (another
 symbol) is the composition operator i.e. you're only using *
 because ASCII doesn't include the 'open oh'.

 However, I was making a different point:  that in group theory math
 texts, we're proud to use regular multiplication and division
 operators for such operations as compositions of functions because
 we're thinking __mul__ and __div__ have that generic meaning -- we
 neither need, nor want, the proliferation of symbols the open oh
 people think we must need.

There are different schools of thought about this actually. I don't
think pride comes into it. Inventing and using specialized symbols is
often useful in math because it provides more context. If you write f
* g the reader would need to know in advance that f and g are
functions or else they wouldn't know what was meant. But if you write
f o g then the reader can *infer* that f and g are functions. Python
happens to use the former (overloading based on argument types);
Python's predecessor ABC used the latter (type inferencing based on
operators). Neither is necessarily better than the other.

There are also fields of mathematics where both are used, with a
different meaning; e.g. f o g would mean functional composition while
f * g could mean the function you get by multiplying f(x) and g(x). In
Python:

def open_oh(f, g):
  return lambda x: f(g(x))

def star(f, g):
  return lambda x: f(x) * g(x)

 Note that by open oh I'm not talking about big oh, a different
 notation that I don't think is redundant, agree with Knuth that if
 your calculus book doesn't include it, you're probably in one of those
 computer illiterate schools (ETS slave, whatever).

I think that comment is a little out of line. BTW big Oh is not part
of calculus, it's part of complexity theory, a totally different field
(more relevant to computers than calculus though).

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] computer algebra

2008-12-10 Thread kirby urner
On Wed, Dec 10, 2008 at 8:27 PM, Guido van Rossum [EMAIL PROTECTED] wrote:

  SNIP 

 There are different schools of thought about this actually. I don't
 think pride comes into it.

Well, *my* school is quite pompous about it.  We think open oh is for sissies.

But that's just us (quirky).  Others more sobering.

 GOOD STUFF 

 Note that by open oh I'm not talking about big oh, a different
 notation that I don't think is redundant, agree with Knuth that if
 your calculus book doesn't include it, you're probably in one of those
 computer illiterate schools (ETS slave, whatever).

 I think that comment is a little out of line. BTW big Oh is not part
 of calculus, it's part of complexity theory, a totally different field
 (more relevant to computers than calculus though).


Not part of calculus as commonly taught today, but *would* be if
Donald Knuth had his way:

http://micromath.wordpress.com/2008/04/14/donald-knuth-calculus-via-o-notation/

Kirby

 --
 --Guido van Rossum (home page: http://www.python.org/~guido/)

___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig


Re: [Edu-sig] computer algebra

2008-12-10 Thread DiPierro, Massimo
The problem is that calculus tends to deal with the concept of infinitesimally 
small and O(eps) is used for small eps. Computer Science tends to deal with 
complexity and O(n) is used for large n. The Big-Oh definitions are different:

i) In calculus f(x) in O(g(x)) iff lim_{x\rightarrow 0} f(x)/g(x)  \infty  

ii) In CS f(x) in O(g(x)) iff lim_{x\rightarrow\infty} f(x)/g(x)  \infty  

It is common to use (i) to teach calculus (I was thought that way) but it is 
not common to use (ii) to teach algorithms. I do so in my notes for Design and 
Analysis of Algorithms [1]
and students like it but many computer scientists believe that using limits is 
just an extra step.

Massimo 

[1]http://bazaar.launchpad.net/%7Emdipierro/algorithms-animator/devel/download/3/csc321notes.pdf-20080914191632-ofooevmsoqqnkrpz-6/csc321notes.pdf?file_id=csc321notes.pdf-20080914191632-ofooevmsoqqnkrpz-6





From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of kirby urner [EMAIL 
PROTECTED]
Sent: Wednesday, December 10, 2008 10:39 PM
To: edu-sig@python.org
Subject: Re: [Edu-sig] computer algebra

On Wed, Dec 10, 2008 at 8:27 PM, Guido van Rossum [EMAIL PROTECTED] wrote:

  SNIP 

 There are different schools of thought about this actually. I don't
 think pride comes into it.

Well, *my* school is quite pompous about it.  We think open oh is for sissies.

But that's just us (quirky).  Others more sobering.

 GOOD STUFF 

 Note that by open oh I'm not talking about big oh, a different
 notation that I don't think is redundant, agree with Knuth that if
 your calculus book doesn't include it, you're probably in one of those
 computer illiterate schools (ETS slave, whatever).

 I think that comment is a little out of line. BTW big Oh is not part
 of calculus, it's part of complexity theory, a totally different field
 (more relevant to computers than calculus though).


Not part of calculus as commonly taught today, but *would* be if
Donald Knuth had his way:

http://micromath.wordpress.com/2008/04/14/donald-knuth-calculus-via-o-notation/

Kirby

 --
 --Guido van Rossum (home page: http://www.python.org/~guido/)

___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig
___
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig