Thank you! The following code produces the same error.

f = x
fp = Piecewise([[(10,20),f]])
fp.riemann_sum_integral_approximation(993)

The student is doing this as an assignment for a class on how to write
programs to solve problems in mathematics. (Newton's Method, Riemann
sums, Fibonacci numbers, Traveling Salesman, etc.) She's not doing
this because she needed SAGE to approximate a Riemann sum. They
started with Maple, and now we're working on SAGE; I'd like to teach
the class exclusively in SAGE one day.

regards
john perry

On Nov 30, 9:00 am, "David Joyner" <[EMAIL PROTECTED]> wrote:
> I'm not sure what the cause of the error is but, FYI, some Riemann sum stuff 
> is
> already implemented in piecewise.py.
>
> On Nov 30, 2007 9:41 AM, john_perry_usm <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > One of my students was writing a procedure to implement a Midpoint
> > Riemann Sum in SAGE. The procedure that she devised is given below,
> > and it looks reasonable enough to me. Unfortunately it generates a
> > SAGE exception (AttributeError, line 2051 of calculus.py) under
> > certain bizarre circumstances; try for example a=10,b=20,f=x,n=991
> > (which works fine) then n=992 with the same a,b,f.
>
> > Any assistance would be appreciated. Maybe I don't know Python well
> > enough? :-) I have verified the exception using both SAGE-2.8.7 on
> > Fedora Core 7 and SAGE-2.8.13 on Windows.
>
> > regards
> > john perry
>
> > Her procedure:
>
> > def Midpoint_Riemann_Sums(a,b,f,n):
> >    delta_x = (b-a)/(n*1.0)
> >    result = 0
> >    for i in range(1, n+1):
> >      xi = ((delta_x/2)+a)+(i*delta_x)
> >      result = result+f(xi)*delta_x
> >    return result
>
> > The error message:
>
> > Traceback (most recent call last):
> >   File "/atlas/perry/sage_notebook/worksheets/apetrinec55/1/code/
> > 71.py", line 4, in <module>
> >     exec
> > compile(ur'Midpoint_Riemann_Sums(Integer(10),Integer(20),f,Integer(1000))'
> > + '\n', '', 'single')
> >   File "/usr/local/sage-2.8.7-fedora_core_7-i686-Linux/data/extcode/
> > sage/", line 1, in <module>
>
> >   File "sage_object.pyx", line 87, in sage_object.SageObject.__repr__
> >   File "/usr/local/sage-2.8.7-fedora_core_7-i686-Linux/local/lib/
> > python2.5/site-packages/sage/calculus/calculus.py", line 2896, in
> > _repr_
> >     return self.simplify()._repr_(simplify=False)
> >   File "/usr/local/sage-2.8.7-fedora_core_7-i686-Linux/local/lib/
> > python2.5/site-packages/sage/calculus/calculus.py", line 2051, in
> > simplify
> >     S =
> > evaled_symbolic_expression_from_maxima_string(self._maxima_init_())
> >   File "/usr/local/sage-2.8.7-fedora_core_7-i686-Linux/local/lib/
> > python2.5/site-packages/sage/calculus/calculus.py", line 3044, in
> > _maxima_init_
> >     return '(%s) %s (%s)' % (ops[0]._maxima_init_(),
>
> > ...and then several hundred more of that last line.
--~--~---------~--~----~------------~-------~--~----~
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
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to