Re: [sage-edu] Extreme graphing

103 views
Skip to first unread message

Dan Drake

unread,
Feb 28, 2013, 5:21:06 PM2/28/13
to sage...@googlegroups.com
On Thu, 28 Feb 2013 at 11:56AM -0800, David Smith wrote:
> I've been experimenting (in an interact) with graphing x^m/e^x for large
> values of m, in order to demonstrate that exp grows faster than any power
> function. This works fine up to m=15, but at 16 (and any higher value) I
> get a long list of errors ending with
>
> ParseFatalException: Expected end of math '$'
> $\verb|1e+12|$ (at char 0), (line:1, col:1)
>
> Wolfram Alpha is perfectly happy to graph this function up to m=125, and after that, it fails only in lopping off the top of the graph because the y-coordinates are too big.
> Is there some reason why Sage can't handle this?

For me, Sage works fine up to x^115. There it starts to complain that it
can't evaluate the function (x^115/e^x) at all points. That seems very
strange to me, although maybe it's running up against the
maximum size that floats can do -- but the plot looks fine, so maybe
not?

Dan

--
--- Dan Drake
----- http://math.pugetsound.edu/~ddrake
-------
signature.asc

kcrisman

unread,
Feb 28, 2013, 9:06:45 PM2/28/13
to sage...@googlegroups.com
I would think this is a matplotlib issue that we are encountering - after all, the error is about 1e+12, or a trillion, so maybe there is something about how we are passing the tick marks on.  David, can you give the *exact* command?

- kcrisman

David Smith

unread,
Mar 1, 2013, 10:59:05 AM3/1/13
to sage...@googlegroups.com

I'm going to explore this a little more and either post the code or a retraction.  I found (after posting), when I put that function into a different graphing interact, that I could push it much farther without failure.  So it may have been some less obvious error in the one I was writing.  More later.  Thanks, guys.

David Smith

unread,
Mar 1, 2013, 12:46:05 PM3/1/13
to sage...@googlegroups.com
I have attached a "graphing calculator" file in which the problem occurs.  When I change the function to x^15/e^x and the range from 0 to 30, everything is fine.  When I change the 15 to 16, I get the error messages pasted in below.  Sorry about the length, but it's a complete mystery to me, so I don't want to leave anything out.  Thanks.

---------------------------------------------------------------------------
ParseFatalException                       Traceback (most recent call last)
<ipython-input-9-7fa122be4bfd> in <module>()
----> 1 sys._sage_.update_interact("ae9084fe-29e6-49b0-bdb6-83a8912c32ba",{"auto_update":True,"x_range":[[u"0",u"30",],],"f":u"x^16/e^x"})

/sagenb/sagecell-hood/sagecell/interact_sagecell.py in update_interact(interact_id, control_vals)
     89         if c.preserve_state:
     90             interact_info["state"][var]=kwargs[var]
---> 91     __interacts[interact_id]["function"](control_vals=kwargs)
     92 
     93 

/sagenb/sagecell-hood/sagecell/interact_sagecell.py in adapted_f(control_vals)
    236         def adapted_f(control_vals):
    237             with session_metadata({'interact_id': interact_id}):
--> 238                 returned=f(**control_vals)
    239             return returned
    240         # update global __interacts

<ipython-input-1-a3966c085f34> in _(f, x_range, auto_update)
      8      html("\[ f (x) = %s \]"%str(latex(f)) )
      9      p1=plot(f, (x,a,b), color='blue', legend_label='$f(x)$', axes_labels=['$x$','$y$'],tick_formatter="latex")
---> 10      show(p1, figsize=Integer(6))

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/misc/functional.pyc in show(x, *args, **kwds)
   1597     if not isinstance(x, (sage.interfaces.expect.Expect, sage.interfaces.expect.ExpectElement)):
   1598         try:
-> 1599             return x.show(*args, **kwds)
   1600         except AttributeError:
   1601             pass

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    454             kwds[self.name + "options"] = suboptions
    455 
--> 456             return func(*args, **kwds)
    457 
    458         #Add the options specified by @options to the signature of the wrapped

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/plot/graphics.pyc in show(self, **kwds)
   1733             kwds.setdefault('filename', sage.misc.misc.graphics_filename())
   1734             filename=kwds['filename']
-> 1735             self.save(**kwds)
   1736             if sage.misc.misc.EMBEDDED_MODE['frontend']=='sagecell':
   1737                 import sys

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    454             kwds[self.name + "options"] = suboptions
    455 
--> 456             return func(*args, **kwds)
    457 
    458         #Add the options specified by @options to the signature of the wrapped

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/plot/graphics.pyc in save(self, filename, **kwds)
   2608 
   2609         # tight_layout adjusts the *subplot* parameters so ticks aren't cut off, etc.
-> 2610         figure.tight_layout()
   2611 
   2612         if fig_tight is True:

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/figure.py in tight_layout(self, renderer, pad, h_pad, w_pad)
   1389                                          subplot_list=subplot_list,
   1390                                          ax_bbox_list=ax_bbox_list,
-> 1391                                          pad=pad, h_pad=h_pad, w_pad=w_pad)
   1392 
   1393         self.subplots_adjust(**kwargs)

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/tight_layout.py in auto_adjust_subplotpars(fig, renderer, nrows_ncols, num1num2_list, subplot_list, ax_bbox_list, pad, h_pad, w_pad, rect)
    115         #ax_bbox = union([ax.get_position(original=True) for ax in subplots])
    116 
--> 117         tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
    118         tight_bbox = TransformedBbox(tight_bbox_raw, fig.transFigure.inverted())
    119 

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/axes.py in get_tightbbox(self, renderer, call_axes_locator)
   8278         if bb_xaxis: bb.append(bb_xaxis)
   8279 
-> 8280         bb_yaxis = self.yaxis.get_tightbbox(renderer)
   8281         if bb_yaxis: bb.append(bb_yaxis)
   8282 

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/axis.py in get_tightbbox(self, renderer)
   1001 
   1002         ticks_to_draw = self._update_ticks(renderer)
-> 1003         ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw, renderer)
   1004 
   1005         self._update_label_position(ticklabelBoxes, ticklabelBoxes2)

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/axis.py in _get_tick_bboxes(self, ticks, renderer)
    986         for tick in ticks:
    987             if tick.label1On and tick.label1.get_visible():
--> 988                 extent = tick.label1.get_window_extent(renderer)
    989                 ticklabelBoxes.append(extent)
    990             if tick.label2On and tick.label2.get_visible():

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/text.py in get_window_extent(self, renderer, dpi)
    745             raise RuntimeError('Cannot get window extent w/o renderer')
    746 
--> 747         bbox, info = self._get_layout(self._renderer)
    748         x, y = self.get_position()
    749         x, y = self.get_transform().transform_point((x, y))

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/text.py in _get_layout(self, renderer)
    307                 w, h, d = get_text_width_height_descent(clean_line,
    308                                                         self._fontproperties,
--> 309                                                         ismath=ismath)
    310             else:
    311                 w, h, d = 0, 0, 0

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py in get_text_width_height_descent(self, s, prop, ismath)
    177         if ismath:
    178             ox, oy, width, height, descent, fonts, used_characters = \
--> 179                 self.mathtext_parser.parse(s, self.dpi, prop)
    180             return width, height, descent
    181 

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/mathtext.py in parse(self, s, dpi, prop)
   2972             self.__class__._parser = Parser()
   2973 
-> 2974         box = self._parser.parse(s, font_output, fontsize, dpi)
   2975         font_output.set_canvas_size(box.width, box.height, box.depth)
   2976         result = font_output.get_results(box)

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/mathtext.py in parse(self, s, fonts_object, fontsize, dpi)
   2350         self._state_stack = [self.State(fonts_object, 'default', 'rm', fontsize, dpi)]
   2351         try:
-> 2352             self._expression.parseString(s)
   2353         except ParseException, err:
   2354             raise ValueError("\n".join([

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseString(self, instring, parseAll)
   1046         if not self.keepTabs:
   1047             instring = instring.expandtabs()
-> 1048         loc, tokens = self._parse( instring, 0 )
   1049         if parseAll:
   1050             StringEnd()._parse( instring, loc )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    922             if self.mayIndexError or loc >= len(instring):
    923                 try:
--> 924                     loc,tokens = self.parseImpl( instring, preloc, doActions )
    925                 except IndexError:
    926                     raise ParseException( instring, len(instring), self.errmsg, self )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2557     def parseImpl( self, instring, loc, doActions=True ):
   2558         if self.expr is not None:
-> 2559             return self.expr._parse( instring, loc, doActions, callPreParse=False )
   2560         else:
   2561             raise ParseException("",loc,self.errmsg,self)

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    922             if self.mayIndexError or loc >= len(instring):
    923                 try:
--> 924                     loc,tokens = self.parseImpl( instring, preloc, doActions )
    925                 except IndexError:
    926                     raise ParseException( instring, len(instring), self.errmsg, self )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2305                     raise ParseSyntaxException( ParseException(instring, len(instring), self.errmsg, self) )
   2306             else:
-> 2307                 loc, exprtokens = e._parse( instring, loc, doActions )
   2308             if exprtokens or exprtokens.keys():
   2309                 resultlist += exprtokens

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    922             if self.mayIndexError or loc >= len(instring):
    923                 try:
--> 924                     loc,tokens = self.parseImpl( instring, preloc, doActions )
    925                 except IndexError:
    926                     raise ParseException( instring, len(instring), self.errmsg, self )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2670         tokens = []
   2671         try:
-> 2672             loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False )
   2673             hasIgnoreExprs = ( len(self.ignoreExprs) > 0 )
   2674             while 1:

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    922             if self.mayIndexError or loc >= len(instring):
    923                 try:
--> 924                     loc,tokens = self.parseImpl( instring, preloc, doActions )
    925                 except IndexError:
    926                     raise ParseException( instring, len(instring), self.errmsg, self )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2305                     raise ParseSyntaxException( ParseException(instring, len(instring), self.errmsg, self) )
   2306             else:
-> 2307                 loc, exprtokens = e._parse( instring, loc, doActions )
   2308             if exprtokens or exprtokens.keys():
   2309                 resultlist += exprtokens

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    922             if self.mayIndexError or loc >= len(instring):
    923                 try:
--> 924                     loc,tokens = self.parseImpl( instring, preloc, doActions )
    925                 except IndexError:
    926                     raise ParseException( instring, len(instring), self.errmsg, self )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2414         for e in self.exprs:
   2415             try:
-> 2416                 ret = e._parse( instring, loc, doActions )
   2417                 return ret
   2418             except ParseException, err:

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    948             else:
    949                 for fn in self.parseAction:
--> 950                     tokens = fn( instring, tokensStart, retTokens )
    951                     if tokens is not None:
    952                         retTokens = ParseResults( tokens,

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/mathtext.py in raise_error(s, loc, toks)
   2047     """
   2048     def raise_error(s, loc, toks):
-> 2049         raise ParseFatalException(msg + "\n" + s)
   2050 
   2051     empty = Empty()


ParseFatalException: Expected end of math '$'
$\verb|1e+12|$ (at char 0), (line:1, col:1)
---------------------------------------------------------------------------
ParseFatalException                       Traceback (most recent call last)
<ipython-input-9-7fa122be4bfd> in <module>()
----> 1 sys._sage_.update_interact("ae9084fe-29e6-49b0-bdb6-83a8912c32ba",{"auto_update":True,"x_range":[[u"0",u"30",],],"f":u"x^16/e^x"})

/sagenb/sagecell-hood/sagecell/interact_sagecell.py in update_interact(interact_id, control_vals)
     89         if c.preserve_state:
     90             interact_info["state"][var]=kwargs[var]
---> 91     __interacts[interact_id]["function"](control_vals=kwargs)
     92 
     93 

/sagenb/sagecell-hood/sagecell/interact_sagecell.py in adapted_f(control_vals)
    236         def adapted_f(control_vals):
    237             with session_metadata({'interact_id': interact_id}):
--> 238                 returned=f(**control_vals)
    239             return returned
    240         # update global __interacts

<ipython-input-1-a3966c085f34> in _(f, x_range, auto_update)
      8      html("\[ f (x) = %s \]"%str(latex(f)) )
      9      p1=plot(f, (x,a,b), color='blue', legend_label='$f(x)$', axes_labels=['$x$','$y$'],tick_formatter="latex")
---> 10      show(p1, figsize=Integer(6))

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/misc/functional.pyc in show(x, *args, **kwds)
   1597     if not isinstance(x, (sage.interfaces.expect.Expect, sage.interfaces.expect.ExpectElement)):
   1598         try:
-> 1599             return x.show(*args, **kwds)
   1600         except AttributeError:
   1601             pass

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    454             kwds[self.name + "options"] = suboptions
    455 
--> 456             return func(*args, **kwds)
    457 
    458         #Add the options specified by @options to the signature of the wrapped

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/plot/graphics.pyc in show(self, **kwds)
   1733             kwds.setdefault('filename', sage.misc.misc.graphics_filename())
   1734             filename=kwds['filename']
-> 1735             self.save(**kwds)
   1736             if sage.misc.misc.EMBEDDED_MODE['frontend']=='sagecell':
   1737                 import sys

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    454             kwds[self.name + "options"] = suboptions
    455 
--> 456             return func(*args, **kwds)
    457 
    458         #Add the options specified by @options to the signature of the wrapped

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/plot/graphics.pyc in save(self, filename, **kwds)
   2608 
   2609         # tight_layout adjusts the *subplot* parameters so ticks aren't cut off, etc.
-> 2610         figure.tight_layout()
   2611 
   2612         if fig_tight is True:

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/figure.py in tight_layout(self, renderer, pad, h_pad, w_pad)
   1389                                          subplot_list=subplot_list,
   1390                                          ax_bbox_list=ax_bbox_list,
-> 1391                                          pad=pad, h_pad=h_pad, w_pad=w_pad)
   1392 
   1393         self.subplots_adjust(**kwargs)

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/tight_layout.py in auto_adjust_subplotpars(fig, renderer, nrows_ncols, num1num2_list, subplot_list, ax_bbox_list, pad, h_pad, w_pad, rect)
    115         #ax_bbox = union([ax.get_position(original=True) for ax in subplots])
    116 
--> 117         tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
    118         tight_bbox = TransformedBbox(tight_bbox_raw, fig.transFigure.inverted())
    119 

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/axes.py in get_tightbbox(self, renderer, call_axes_locator)
   8278         if bb_xaxis: bb.append(bb_xaxis)
   8279 
-> 8280         bb_yaxis = self.yaxis.get_tightbbox(renderer)
   8281         if bb_yaxis: bb.append(bb_yaxis)
   8282 

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/axis.py in get_tightbbox(self, renderer)
   1001 
   1002         ticks_to_draw = self._update_ticks(renderer)
-> 1003         ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw, renderer)
   1004 
   1005         self._update_label_position(ticklabelBoxes, ticklabelBoxes2)

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/axis.py in _get_tick_bboxes(self, ticks, renderer)
    986         for tick in ticks:
    987             if tick.label1On and tick.label1.get_visible():
--> 988                 extent = tick.label1.get_window_extent(renderer)
    989                 ticklabelBoxes.append(extent)
    990             if tick.label2On and tick.label2.get_visible():

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/text.py in get_window_extent(self, renderer, dpi)
    745             raise RuntimeError('Cannot get window extent w/o renderer')
    746 
--> 747         bbox, info = self._get_layout(self._renderer)
    748         x, y = self.get_position()
    749         x, y = self.get_transform().transform_point((x, y))

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/text.py in _get_layout(self, renderer)
    307                 w, h, d = get_text_width_height_descent(clean_line,
    308                                                         self._fontproperties,
--> 309                                                         ismath=ismath)
    310             else:
    311                 w, h, d = 0, 0, 0

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py in get_text_width_height_descent(self, s, prop, ismath)
    177         if ismath:
    178             ox, oy, width, height, descent, fonts, used_characters = \
--> 179                 self.mathtext_parser.parse(s, self.dpi, prop)
    180             return width, height, descent
    181 

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/mathtext.py in parse(self, s, dpi, prop)
   2972             self.__class__._parser = Parser()
   2973 
-> 2974         box = self._parser.parse(s, font_output, fontsize, dpi)
   2975         font_output.set_canvas_size(box.width, box.height, box.depth)
   2976         result = font_output.get_results(box)

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/mathtext.py in parse(self, s, fonts_object, fontsize, dpi)
   2350         self._state_stack = [self.State(fonts_object, 'default', 'rm', fontsize, dpi)]
   2351         try:
-> 2352             self._expression.parseString(s)
   2353         except ParseException, err:
   2354             raise ValueError("\n".join([

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseString(self, instring, parseAll)
   1046         if not self.keepTabs:
   1047             instring = instring.expandtabs()
-> 1048         loc, tokens = self._parse( instring, 0 )
   1049         if parseAll:
   1050             StringEnd()._parse( instring, loc )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    922             if self.mayIndexError or loc >= len(instring):
    923                 try:
--> 924                     loc,tokens = self.parseImpl( instring, preloc, doActions )
    925                 except IndexError:
    926                     raise ParseException( instring, len(instring), self.errmsg, self )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2557     def parseImpl( self, instring, loc, doActions=True ):
   2558         if self.expr is not None:
-> 2559             return self.expr._parse( instring, loc, doActions, callPreParse=False )
   2560         else:
   2561             raise ParseException("",loc,self.errmsg,self)

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    922             if self.mayIndexError or loc >= len(instring):
    923                 try:
--> 924                     loc,tokens = self.parseImpl( instring, preloc, doActions )
    925                 except IndexError:
    926                     raise ParseException( instring, len(instring), self.errmsg, self )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2305                     raise ParseSyntaxException( ParseException(instring, len(instring), self.errmsg, self) )
   2306             else:
-> 2307                 loc, exprtokens = e._parse( instring, loc, doActions )
   2308             if exprtokens or exprtokens.keys():
   2309                 resultlist += exprtokens

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    922             if self.mayIndexError or loc >= len(instring):
    923                 try:
--> 924                     loc,tokens = self.parseImpl( instring, preloc, doActions )
    925                 except IndexError:
    926                     raise ParseException( instring, len(instring), self.errmsg, self )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2670         tokens = []
   2671         try:
-> 2672             loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False )
   2673             hasIgnoreExprs = ( len(self.ignoreExprs) > 0 )
   2674             while 1:

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    922             if self.mayIndexError or loc >= len(instring):
    923                 try:
--> 924                     loc,tokens = self.parseImpl( instring, preloc, doActions )
    925                 except IndexError:
    926                     raise ParseException( instring, len(instring), self.errmsg, self )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2305                     raise ParseSyntaxException( ParseException(instring, len(instring), self.errmsg, self) )
   2306             else:
-> 2307                 loc, exprtokens = e._parse( instring, loc, doActions )
   2308             if exprtokens or exprtokens.keys():
   2309                 resultlist += exprtokens

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    922             if self.mayIndexError or loc >= len(instring):
    923                 try:
--> 924                     loc,tokens = self.parseImpl( instring, preloc, doActions )
    925                 except IndexError:
    926                     raise ParseException( instring, len(instring), self.errmsg, self )

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2414         for e in self.exprs:
   2415             try:
-> 2416                 ret = e._parse( instring, loc, doActions )
   2417                 return ret
   2418             except ParseException, err:

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
    979         else:
    980             try:
--> 981                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
    982                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())
    983                 return value

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
    948             else:
    949                 for fn in self.parseAction:
--> 950                     tokens = fn( instring, tokensStart, retTokens )
    951                     if tokens is not None:
    952                         retTokens = ParseResults( tokens,

/sagenb/sagecell-hood/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/matplotlib/mathtext.py in raise_error(s, loc, toks)
   2047     """
   2048     def raise_error(s, loc, toks):
-> 2049         raise ParseFatalException(msg + "\n" + s)
   2050 
   2051     empty = Empty()


ParseFatalException: Expected end of math '$'
$\verb|1e+12|$ (at char 0), (line:1, col:1)
Powered by Sage
sage-graphing-calculator-f(x).html

kcrisman

unread,
Mar 1, 2013, 2:02:21 PM3/1/13
to sage...@googlegroups.com
For reference,

x = var("x")

@interact
def _(f = input_box(x, label='$f(x) = $', width=40), x_range=input_grid(1,2,[[-8,8]], label='$x$ range', width=10), auto_update=False):
     a,b=x_range[0]
     html("\[ f (x) = %s \]"%str(latex(f)) )
     p1=plot(f, (x,a,b), color='blue', legend_label='$f(x)$', axes_labels=['$x$','$y$'],tick_formatter="latex")
     show(p1, figsize=6)

Jason Grout

unread,
Mar 1, 2013, 2:06:54 PM3/1/13
to sage...@googlegroups.com
As a workaround, delete the tick_formatter="latex".

This looks like possibly a bug in matplotlib.

Thanks,

Jason

David Smith

unread,
Mar 2, 2013, 4:04:51 PM3/2/13
to sage...@googlegroups.com
Thanks, Jason.  I never would have thought of that, but on reflection, it appeared that the latex formatter would never switch to scientific notation, and this is a case where you definitely want it.  I suppose the error was when it ran out of room for all those digits.  With that removed, Sage is perfectly happy to graph x^100/e^x.

David

John Travis

unread,
Mar 6, 2013, 3:55:58 PM3/6/13
to sage...@googlegroups.com
Just for the fun of it, I was playing with:

@interact
def _(m=slider(1,250,1,1)):
      plot(x^m/e^x,(x,0,2*m)).show()

and things work really nice till m = 128.  After that, it still runs but the graph has horizontal issues--using either aleph or 5.5.

JT

David Smith

unread,
Mar 19, 2013, 5:30:59 PM3/19/13
to sage...@googlegroups.com
I like this even better that what I was doing for the intended illustration in our book.  The URL is https://www.math.duke.edu/education/calculustext-rev11/Chapter10/Section10-3/Chapter10-3-3M.html and the interact is at the very bottom of the page.  Thanks, John.
Reply all
Reply to author
Forward
0 new messages