The problem you are running into is that when you are on the command
line, all the needed functions are loaded (this is a reason why the Sage
startup takes time). When you are writing your own library, you need to
import modules that you need.
You can do that by simply adding
from sage.all import *
at the top of your file. If you want to have finer grained import, then
you will need to look at the function you are calling. You can either
look at the help by doing (for example)
solve?
or by
solve.func_code
The help mentions the path name to solve. The latter command gives only
the path name which in this case ends in
sage-5.0.beta2/local/lib/python2.7/site-packages/sage/symbolic/relation.py
(I don't know if there is a better way to know the module that you need
to import.)
So, to import only the solve function, you will need to include stuff
under sage/...
from sage.symbolic.relation import solve
The same can be done with diff, etc.
On 05/01/2012 01:16 PM, yogesh gupta wrote:
thanks for your help. your given method is perfectly working.
but now i have another problem.
i have another library which i want to add ----
def length(w,res,ll,ul,p):
from sage.symbolic.ring import SR
x,y=SR.var('x y')
z=solve(w,y)[0].right()
q=w.diff(x)
r=w.diff(y)
if(res==x):
w=-q/r
else:
w=-r/q
w=sqrt(w*w+1)
flength=p*integrate(w(y=z),res,ll,ul)
return flength
We had included this into our
sage test copy but when we try to call it from sage command
prompt then it gives error that "global name solve is not
defined" how to resolve this problem ?
and i think that it will also give same problems in diff() and
integrate() function.so plz help me.
--
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-support
URL: http://www.sagemath.org