On Tue, Jan 6, 2009 at 8:06 AM, lfmartins <[email protected]> wrote: > > What would be the best way, for students, to define functions of an > arbitrary (but fixed) number of variables? > > What I am using right now is a function: > > def makevars(prefix, n): > return var(' '.join([prefix+str(i) for i in range(n)])) > > So, for example: > > x=makevars('x',5) > > Creates the 5 variables (x0, x1, x2, x3, x4) and assigns then to x. > Then you can write stuff like: > > fexpr = sum(sin(v)^2 for v in x); fexpr > > and do calculus: > > diff(fexpr,x1) > > Is this a decent way to do it, or there is something predefined, and > I'm reinventing a wheel?
That seems decent. > I wanted to put my worksheet on sagenb.org, but the server seems to be > down. I uploaded the .sws file to the group files. It's not down. You probably hit it during the minute a day when it takes a snapshot of its running state for security purposes. Please try again. -- William --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sage-edu" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-edu?hl=en -~----------~----~----~----~------~----~------~--~---
