[Edu-sig] using Python as a calculator

kirby urner kirby.urner at gmail.com
Sun Apr 11 23:51:35 CEST 2010


>> Sorry, I don't know J (Kirby does), but this is exactly the reason I prefer
>> Python. Readability counts (for me).
>
> That's what they said to Fibonacci when he tried to explain why Arabic
> numerals were better for math than Roman numerals. But Roman numerals
> are better in readability and algorithmic complexity if you rarely do
> anything but add and subtract, as merchants did before interest
> payments became critical. Roman numerals are precisely equivalent to
> abacus notation. It is odd that the distinction between math/science
> programming and business programming is nearly a thousand years old,
> but there it is.
>

Fibonacci's Liber Abaci introduced the Indian/Arabic number system,
based on the abacus.  The place value system corresponds to the
rods of the abacus, with the zero corresponding to a rod with no beads
(a place holder).

Roman numerals, in contrast, have nothing to do with abacus notation
and have no place value e.g XIV for 14 or MMMCCC for 3300.

http://www.novaroma.org/via_romana/numbers.html

Roman numbers suck for arithmetic operations of any kind IMO.

> numbers =. i. 11  NB. 0..10
>

...similar to Python's range built-in.

> These objections are trivial and uninformed. You aren't a
> mathematician, you don't like math and math notation, so there is
> nothing more to say, except please stand out of the way of people who
> can benefit from it and want it.
>

One could argue any computer language comprises a math notation.

Also, one could argue that all creatures are mathematicians in some
innate way (Keith Devlin's point).

Carving out a special caste of humans and calling them "mathematicians"
is a practice within various institutions.

I've noticed many of these institutions promote a kind of snobbery,
but then such is the human ego.

> You can append a table to a table if they have a dimension in common.
> You can't append a table to a list unless the list is turned into a
> one-row table.
>

Note that numpy shares some of APL's and J's ability to shape data
into multi-dimensional objects with rank.

>>> import numpy
>>> a = numpy.array(range(10))
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> a.reshape((2,5))
array([[0, 1, 2, 3, 4],
       [5, 6, 7, 8, 9]])
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> a = a.reshape((2,5))
>>> a
array([[0, 1, 2, 3, 4],
       [5, 6, 7, 8, 9]])
>>> numpy.concatenate((a,a))
array([[0, 1, 2, 3, 4],
       [5, 6, 7, 8, 9],
       [0, 1, 2, 3, 4],
       [5, 6, 7, 8, 9]])
>>> numpy.concatenate((a,a), axis=1)
array([[0, 1, 2, 3, 4, 0, 1, 2, 3, 4],
       [5, 6, 7, 8, 9, 5, 6, 7, 8, 9]])

>>> I can easily give you a short sequence of lessons leading to this
>>> level, introducing some other arithmetic, transcendental, and
>>> array-handling functions along the way, and a little more about
>>> operating on functions to define new functions.
>>
>> Python is much nearer to standard Math-notation, that is a good thing.
>
> LOL. Math notation is what mathematicians use, not schoolchildren.

Math notations, like music notations, are the common heritage of
humankind, not the special property of an elite caste of human.

That being said, many math notations, including computer languages,
are quite opaque until deciphered.

Those already "in the know" may exult in their exclusive knowledge,
that's been true since time immemorial.

Those cryptic expressions on a T-shirt from the MIT gift shop serve
as mnemonics, are reminders of long hours spent unpacking the
meanings.

To a non-initiate, it all looks like so much unreadable APL. :)

Of course non-math notations share in these encrypting / compacting
capabilities.  You needn't use math notations to create operational
systems (institutions) with their respective insiders and outsiders,
with insiders often ranked according to their "degree" of inner-ness.

We've not really defined "mathematics", "mathematician" or
"math notation" for the purposes of this thread, so maybe one
could argue that all notations are inherently mathematical in
that they're aids to thought processes, which processes by their
very nature are computational in some degree.

Is Chinese a math notation?  Write a 500 word essay on why it
is.  Write another 500 word essay on why it isn't.

> They are constantly inventing more of it. What you call math notation
> is known to mathematicians as "arithmetic".
>

Iverson called APL an executable math notation (MN).  MNs were
divided into machine-executable and not.

Leibniz dreamed of machine-executable logical languages.  We have
them now, call them "computer languages".

> There is no standard math notation.
>

Nor is there a strongly fixed meaning to the concept of "math
notation".  Is Python a math notation?  One could argue that it
is.  Or call it a machine-executable logic.

> Polish: + 1 2
> Infix: 1 + 2
> Reverse Polish: 1 2 +
>
> Reverse Polish is one of the two standard calculator input systems,
> the one used by engineers, from HP. Polish is standard in LISP and
> combinatory logic. Neither requires parentheses. Infix notation, as on
> TI and related calculators, requires parentheses, and is much more
> difficult for complex expressions.
>
>> I like to learn new languages - up to a point. I don't see the added value of
>> J in this case.
>
> I like to learn languages a lot more than you, then. I don't consider
> anybody educated in computing without knowing something of languages
> from the LISP, APL, FORTH, OOP, and scalar language families.
>

"Like" may not be the operative word in all cases.  Some people just
don't have the privilege to study that much.  I wish that they did.

Socrates worked with that slave boy to show how intelligence was
innate, but he didn't manage to abolish slavery.

This is clearly a Python list, so I'm never going to apologize for showing
a Pythonic solution or implementation that could just as well be done
in another language in far fewer steps.

I'm happy to have APL and J mentioned for comparing and contrasting
(I mention them myself), but if one judges one needs to stick with
Python for a given task (because it's what they know, and because
the task is looming), then it's hardly my place to judge them mentally
and/or morally deficient in some way.

>> Just my 2c
>>
>> Christian
>>

Thanks for your remarks Christian.  Don't let this Ed character bully
or intimidate you.  He likes to show off, which is fine, but he lacks
diplomatic skills IMO.  But then some say the same about me.

Kirby

>> _______________________________________________
>> Edu-sig mailing list
>> Edu-sig at python.org
>> http://mail.python.org/mailman/listinfo/edu-sig
>>
>
>
>
> --
> Edward Mokurai (默雷/धर्ममेघशब्दगर्ज/دھرممیگھشبدگر ج) Cherlin
> Silent Thunder is my name, and Children are my nation.
> The Cosmos is my dwelling place, the Truth my destination.
> http://www.earthtreasury.org/
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig
>


More information about the Edu-sig mailing list