[sage-support] Re: region plot error

2010-01-01 Thread Jason Grout
Marshall Hampton wrote:
> That definitely looks like a bug.  It seems to be in the fast_float
> command, called by setup_for_eval_on_grid.  Hopefully someone more
> familiar with fast_float can comment on what is going wrong.
> 

First, there is a bug, presumably in setup_for_eval_on_grid, where the 
variables are erroneously switched.  Here is the call with a bit of 
debugging showing the arguments to fast_float.  Note that the function 
has arguments "y,x", but the variables passed to fast_float are "x,y":

  sage: region_plot(2/x + 1/y > 1/x * 1/y, (x,-10,10), (y,-10,10)).show()
[(y, x) |--> -2/x - 1/y + 1/(x*y)] [x, y] {}

I've made this ticket 7809, and posted a patch (please review!).  In 
practice, this probably does not change anything, but the code should be 
cleaner and more correct after the patch is applied.

Second, the issue above appears to be a bug in fast_callable (which 
fast_float calls).  I've made this 
http://trac.sagemath.org/sage_trac/ticket/7810


sage: fast_float(-1/x-1/y+1/(x*y),x,y)
---
TypeError Traceback (most recent call last)

/home/grout/.sage/temp/tiny/2056/_home_grout__sage_init_sage_0.py in 
()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_eval.so
 
in sage.ext.fast_eval.fast_float (sage/ext/fast_eval.c:8434)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so
 
in sage.ext.fast_callable.fast_callable (sage/ext/fast_callable.c:3134)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression.so
 
in sage.symbolic.expression.Expression._fast_callable_ 
(sage/symbolic/expression.cpp:24715)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc
 
in fast_callable(ex, etb)
1353
1354 """
-> 1355 return FastCallableConverter(ex, etb)()
1356
1357 class RingConverter(Converter):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc
 
in __call__(self, ex)
 212 div = self.get_fake_div(ex)
 213 return self.arithmetic(div, div.operator())
--> 214 return self.arithmetic(ex, operator)
 215 elif operator in relation_operators:
 216 return self.relation(ex, operator)

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc
 
in arithmetic(self, ex, operator)
1293 elif operator is _operator.neg:
1294 return self.etb.call(operator, operands[0])
-> 1295 return reduce(lambda x,y: self.etb.call(operator, x,y), 
operands)
1296
1297 def symbol(self, ex):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc
 
in (x, y)
1293 elif operator is _operator.neg:
1294 return self.etb.call(operator, operands[0])
-> 1295 return reduce(lambda x,y: self.etb.call(operator, x,y), 
operands)
1296
1297 def symbol(self, ex):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so
 
in sage.ext.fast_callable.ExpressionTreeBuilder.call 
(sage/ext/fast_callable.c:4986)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/ext/fast_callable.so
 
in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ 
(sage/ext/fast_callable.c:4313)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression.so
 
in sage.symbolic.expression.Expression._fast_callable_ 
(sage/symbolic/expression.cpp:24715)()

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc
 
in fast_callable(ex, etb)
1353
1354 """
-> 1355 return FastCallableConverter(ex, etb)()
1356
1357 class RingConverter(Converter):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc
 
in __call__(self, ex)
 211 if getattr(self, 'use_fake_div', False) and 
operator is _operator.mul:
 212 div = self.get_fake_div(ex)
--> 213 return self.arithmetic(div, div.operator())
 214 return self.arithmetic(ex, operator)
 215 elif operator in relation_operators:

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc
 
in arithmetic(self, ex, operator)
1293 elif operator is _operator.neg:
1294 return self.etb.call(operator, operands[0])
-> 1295 return reduce(lambda x,y: self.etb.call(operator, x,y), 
operands)
1296
1297 def symbol(self, ex):

/home/grout/downloads/sage-4.3/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.pyc
 
in (x, y)
1293 elif oper

[sage-support] Re: region plot error

2010-01-01 Thread Marshall Hampton
That definitely looks like a bug.  It seems to be in the fast_float
command, called by setup_for_eval_on_grid.  Hopefully someone more
familiar with fast_float can comment on what is going wrong.

-M.Hampton

On Dec 31 2009, 5:30 pm, TianWei  wrote:
> When I try the following:
>
> sage:  x,y = var('x,y')
> sage:  region_plot(1/x + 1/y > 1/x * 1/y, (x,-10,10), (y,-10,10)).show
> ()
>
> I get an error (the last line of the Traceback is reproduced below):
>
> TypeError: reduce() of empty sequence with no initial value
>
> This error occurs in both the notebook and at the Sage prompt. I found
> this in versions 4.1.2 to 4.3, but I don't know about the versions
> before 4.1.2.
>
> Interestingly, the following commands work:
>
> sage:  region_plot(1/x + 1/y < 1/x * 1/y, (x,-10,10), (y,-10,10)).show
> () # '>' changed to '<'
> sage:  implicit_plot(1/x + 1/y == 1/x * 1/y, (x,-10,10),
> (y,-10,10)).show()
>
> I'm not very proficient at using Sage, so I appreciate any ideas and
> advice.
>
> Tianwei

-- 
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
URL: http://www.sagemath.org