How does Python help with Calculus?

kirby urner <[email protected]>
Newsgroups gmane.comp.python.education
Message-ID <CAPJgG3QwdBNs8vjukn02oSxqfg4DgrmgooCYm8rYHqGy_o7EAA@mail.gmail.com>
The obvious answer is via Sage and SymPy, which will do differentiation and
integration symbolically to some degree.

http://www.scipy-lectures.org/advanced/sympy.html#differentiation

However even plain old core Python helps in that students get a sense of
functions as top-level citizens. I'm not saying Python is alone in
providing this.

If the C language could be written:

function func(function f1, function f2):{ }

with type function both eaten and returned, then we could use C for this
kind of thing also.

http://mathforum.org/kb/message.jspa?messageID=10168568  (more on this
general topic)

The repl below (you may skip modal window) shows my latest slimmed down
version of Compose, something I introduce to the O'Reilly course as well.

https://repl.it/HxMo/2

Function type objects don't ordinarily multiply but what if we want to
write h = f * g instead of h(x) = f(g(x)).

For one thing, why mention x at this point (the argument object) as we're
simply defining a function, not calling it with an input right?

The Compose class is just the ticket, swallowing and wrapping a function
with a __mul__ API. Now * is your compose operator.  Or use __matmul__ for
@ symbol.

Note then, the use of Compose as a class decorator to the same end.

Feel free to recycle this animal in your own lesson plans.  MIT license or
whatever.

Kirby

PS:  one of the Pycon keynotes was about the affordability of nuke energy,
with the claim / calculation that it's less risky to workers than coal.  I
didn't have time to go up to the podium after and listen in on the
conversation. We should have started a BOF.  Simulating / modeling risk is
something I'm into through CERM Academy.  We could start a thread on
Facebook.

_______________________________________________
Edu-sig mailing list
[email protected]
https://mail.python.org/mailman/listinfo/edu-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.