Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

help with simple integration of piecewise function?

r = var('r')
Piecewise([[(1,2), 1/floor(r)]]).integral(r,1,2)

Gives an error:

Error in lines ... 
AttributeError: 'sage.rings.integer.Integer' object has no attribute 'variables

What am I doing wrong? I note that

Piecewise([[(1,2), 1/floor(r)]]).integral(r)

gives output ``Piecewise defined function with 1 parts, [[(1, 2), r1 |--> integrate(1/floor(r1), r1, 1, r1)]]''.

And that

integrate(1/floor(r1), r1, 1, r1)(2)

gives the same error as the first attempt.

help with simple integration of piecewise function?

r = var('r')
Piecewise([[(1,2), 1/floor(r)]]).integral(r,1,2)

Gives an error:

Error in lines ... 
AttributeError: 'sage.rings.integer.Integer' object has no attribute 'variables

What am I doing wrong? I note that

Piecewise([[(1,2), 1/floor(r)]]).integral(r)

gives output ``Piecewise defined function with 1 parts, [[(1, 2), r1 |--> integrate(1/floor(r1), r1, 1, r1)]]''.

And that

integrate(1/floor(r1), r1, 1, r1)(2)

gives the same error as the first attempt.

attempt. Here's the full stacktrace of the error:

EDIT: Thanks. Here's the full stack trace for the error:

File "/Applications/Sage-6.3.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py", line 833, in integral
return F(b) - F(a)
File "/Applications/Sage-6.3.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py", line 665, in __call__
return self.functions()[n-1](x0)
File "expression.pyx", line 4391, in sage.symbolic.expression.Expression.__call__ (build/cythonized/sage/symbolic/expression.cpp:21933)
File "/Applications/Sage-6.3.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/callable.py", line 477, in _call_element_
return SR(_the_element.substitute(**d))
File "expression.pyx", line 4242, in sage.symbolic.expression.Expression.substitute (build/cythonized/sage/symbolic/expression.cpp:21183)
File "/Applications/Sage-6.3.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 161, in _eval_
if len(x.variables()) == 1:
File "element.pyx", line 344, in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4022)
File "misc.pyx", line 257, in sage.structure.misc.getattr_from_other_class (build/cythonized/sage/structure/misc.c:1775)
AttributeError: 'sage.rings.integer.Integer' object has no attribute 'variables'

help with simple integration of piecewise function?

r = var('r')
Piecewise([[(1,2), 1/floor(r)]]).integral(r,1,2)

Gives an error:

Error in lines ... 
AttributeError: 'sage.rings.integer.Integer' object has no attribute 'variables

What am I doing wrong? I note that

Piecewise([[(1,2), 1/floor(r)]]).integral(r)

gives output ``Piecewise defined function with 1 parts, [[(1, 2), r1 |--> integrate(1/floor(r1), r1, 1, r1)]]''.

And that

integrate(1/floor(r1), r1, 1, r1)(2)

gives the same error as the first attempt. Here's the full stacktrace of the error:

EDIT: Thanks. Here's the full stack trace for the error:

File "/Applications/Sage-6.3.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py", line 833, in integral
return F(b) - F(a)
 File "/Applications/Sage-6.3.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py", line 665, in __call__
return self.functions()[n-1](x0)
 File "expression.pyx", line 4391, in sage.symbolic.expression.Expression.__call__ (build/cythonized/sage/symbolic/expression.cpp:21933)
 File "/Applications/Sage-6.3.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/callable.py", line 477, in _call_element_
return SR(_the_element.substitute(**d))
 File "expression.pyx", line 4242, in sage.symbolic.expression.Expression.substitute (build/cythonized/sage/symbolic/expression.cpp:21183)
 File "/Applications/Sage-6.3.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 161, in _eval_
if len(x.variables()) == 1:
 File "element.pyx", line 344, in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4022)
 File "misc.pyx", line 257, in sage.structure.misc.getattr_from_other_class (build/cythonized/sage/structure/misc.c:1775)
AttributeError: 'sage.rings.integer.Integer' object has no attribute 'variables'