![](https://secure.gravatar.com/avatar/a0580a283826e1c8cf51b77d3a9c67e9.jpg?s=120&d=mm&r=g)
My students and I solved last year's AP Calculus exam with python last year for fun! Have a look, http://shadowfaxrant.blogspot.com/2016/06/how-to-part-ii-pythonic-calculus.h... HTH, AJG Sent from BlueMail On Jun 10, 2017, 3:20 PM, at 3:20 PM, kirby urner <kirby.urner@gmail.com> wrote:
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.
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 Edu-sig@python.org https://mail.python.org/mailman/listinfo/edu-sig