[Edu-sig] More calculus in Python
Arthur
ajsiegel at optonline.net
Sat Jan 1 14:49:36 CET 2005
>>Not either/or, but no concrete plans over here right now.
>>Kirby
Turns out there is no more to plotting the function and its derivative using
Vpython than adding this your calc.py module:
if __name__ == "__main__":
newp = p1 * p1 * p1
from visual.graph import *
uplot = gcurve(color=color.cyan) # a connected curve object
for x in arange(-5, 6.1, 0.1): # x goes from -5 to 6
uplot.plot(pos=(x,newp.u(x))) # plot
uplot = gcurve(color=color.red) # a connected curve object
for x in arange(-5., 6.1, 0.1): # x goes from -5 to 6
uplot.plot(pos=(x,newp.du(x))) # plot
By varying the definition of newp one gets some quick visual feedback of the
"shape" of functions and their derivatives. All to better effect, IMO, than
the static illustrations one sees in a text - assuming that following the
logic of the calc.py code is a required part of the learning process.
Not that following the logic of the code is particularly easy - but at least
one's efforts can be concentrated on just that - following the *logic* -
the code as code, in Python, being pretty transparent.
Art
More information about the Edu-sig
mailing list