Great! It works. It is exactly what I needed. By the way. If I execute test.sage, sage creates a new file called sage.py. Is there a way to prevent that?
On May 29, 9:45 am, davidloeffler <dave.loeff...@gmail.com> wrote: > Another alternative: if you call your file "test.sage" rather than > "test.py", and then do "sage test.sage" from the command line, it will > be run as if you had typed all the corresponding commands in a Sage > session, so you don't need the "from sage.all import *" line in > Laurent's example above. > > David > > On May 29, 12:33 pm, Laurent <moky.m...@gmail.com> wrote: > > > Sage is a python module. > > > The following is an example which defines a class from which you can > > manipulate functions : > > > ------------------------------------------------- > > > #! /usr/bin/sage -python > > # -*- coding: utf8 -*- > > > from sage.all import * > > > class MaClasse(object): > > def __init__(self,exp): > > self.sage = exp > > self.sageFast = self.sage._fast_float_(x) > > def Derr(self): > > return MaClasse(self.sage.derivative()) > > def Evaluation(self,xe): > > return numerical_approx(self.sageFast(xe)) > > > var('x,y') > > f = MaClasse(x**2+2) > > > print f.Derr().sage > > print f.Derr().Evaluation(3) > > print f.Evaluation(8) > > > -------------------------------------- > > > Copy-paste it in a text file, make it executable, and enjoy ! > > > Laurent --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---