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.

On Mon, Apr 30, 2012 at 10:43 PM, P Purkayastha <[email protected]> wrote:

> I tested by defining the function in the notebook and it worked. The
> reason why it works in the notebook is because Sage preparses the input
> that you provide it. By default it preparses x to make it a symbolic
> variable. I am just surprised that var() does not work if you make your
> function a library. Looking at the help shows that it is made to work only
> for interactive use.
>
> To make it work from within the Sage library you will need to define the
> variable as a symbolic variable. The code to do this should be like this:
>
> def symmetry(w):
>        from sage.symbolic.ring import SR
>        x,y = SR.var('x, y')
>
> I suppose the above should work. I haven't tested it as yet.
>
>
> On 05/01/2012 12:50 AM, yogesh gupta wrote:
>
>>
>>
>> ---------- Forwarded message ----------
>> From: *yogesh gupta* <[email protected] <mailto:[email protected]
>> >**>
>> Date: Mon, Apr 30, 2012 at 10:19 PM
>> Subject: Re: [sage-support] Re: including sage library
>> To: [email protected] 
>> <mailto:sage-support@**googlegroups.com<[email protected]>
>> >
>>
>>
>> thanks for reply.
>> first method is worked perfectly. But in the second method it says
>> "global name var is not defined". and i want to implement the libraries
>> in the fashion so that i have to pass as minimum as possible arguments.
>> so plz help me.
>>
>>
>> On Mon, Apr 30, 2012 at 7:37 PM, P Purkayastha <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>>
>>
>>    On Monday, April 30, 2012 8:11:29 PM UTC+8, yogesh wrote:
>>
>>        Hello Sir,
>>
>>        def symmetry(w):
>>             if(w==w(x=-x,y=-y)):
>>                     print "symmetrical about origin"
>>             else:
>>                 print "not symmetrical about origin"
>>
>>             if(w==w(x=-x)):
>>                     print "symmetrical about y axis"
>>             else:
>>                 print "not symmetrical about y axis"
>>             if(w==w(y=-y)):
>>                     print "symmetrical about x axis"
>>             else:
>>                 print "not symmetrical about x axis"
>>             if(w==w(x=y,y=x)):
>>                     print "symmetrical about y=x line"
>>             else:
>>                 print "not symmetrical about y=x line"
>>
>>
>>        var('x y a')
>>        w=x^2+y^2-a^2
>>
>>        html("<h2>Find the symmetry of a curve </h2>")
>>        symmetry(w)
>>
>>        this is our function symmetry. 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 variable x is not
>>        defined" how to resolve this problem ??????/
>>
>>        plz reply asap. We need it very urgent.
>>        Thanks
>>
>>    You can either
>>    1. pass the variables into your function as in
>>    ||
>>    defsymmetry(w,x,y):
>>
>>
>>    2. Declare x and y inside the function:
>>    ||
>>    defsymmetry(w):
>>         x,y =var('x y');
>>
>>
>>    --
>>    To post to this group, send email to [email protected]
>>    <mailto:sage-support@**googlegroups.com<[email protected]>
>> >
>>
>>    To unsubscribe from this group, send email to
>>    
>> sage-support+unsubscribe@**googlegroups.com<sage-support%[email protected]>
>>    
>> <mailto:sage-support%**[email protected]<sage-support%[email protected]>
>> **>
>>
>>    For more options, visit this group at
>>    
>> http://groups.google.com/**group/sage-support<http://groups.google.com/group/sage-support>
>>    URL: http://www.sagemath.org
>>
>>
>>
>>
>

-- 
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

Reply via email to