Re: [sage-devel] Test the "binomial" function in an expression
Hi Francois, On Thu, 07 Oct 2010 22:39:38 +0200 Francois Maltey wrote: > Now I want to test an expression with the binomial function call. > > y = binomial (3*x, x)# is fine > op = y.operator() # is also fine > op # I get binomial > op == binomial # remains False The top level binomial() function is the one defined in sage.rings.arith. The symbolic binomial function is defined in sage.functions.other: sage: SR(2).binomial(x) binomial(2, x) sage: SR(2).binomial(x).operator().__module__ 'sage.functions.other' sage: binomial.__module__ 'sage.rings.arith' It looks like the top level binomial() function is a mess already. - binomial does not accept variable when only in the lower argument http://trac.sagemath.org/sage_trac/ticket/9634 - binomial does not accept float http://trac.sagemath.org/sage_trac/ticket/9633 Looking at the code in sage/rings/arith.py, I see that the if statement starting at line 2999 is a duplicate of that in at line 2961. Replacing the top level binomial function with the symbolic one defined in sage.functions.other should provide an easy fix for all these problems. I wonder if it effects the speed too much. > How can I do this test for binomial ? As a workaround you can test if the operator is the function defined in sage.functions.other. sage: y = binomial(3*x, x) sage: y.operator() binomial sage: y.operator() is sage.functions.other.binomial True Cheers, Burcin -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Test the "binomial" function in an expression
Hello, I play with expressions, and transform sin(x) to (exp(i*x)-exp(-i*x))/2. So I use a lot of test as var ('x') y = cos(x) # or any other expression" op = y.operator # so op == cos if op == cos : ... # this test is fine, not the next one else : ... Now I want to test an expression with the binomial function call. y = binomial (3*x, x)# is fine op = y.operator() # is also fine op # I get binomial op == binomial # remains False Type(s) are differents for binomial but are the sames for sin : type (op), type(binomial) # type are differents , sage: type(sin(x).operator()), type(sin) (, 'sage.functions.trig.Function_sin'>) How can I do this test for binomial ? I don't want to use match and SR.wild(n) because I can't insert inside the match. Do you have any idea ? Many thanks. F. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org