Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

pi and e not evaluated when i use my own classes

This question might be related to this question: http://ask.sagemath.org/question/966/problem-with-sign-sgn-and-n

I have a symbolic calculation and I do evaluate it numerically. Within one of my classes (within my notebook; no external files) I evaluate this term

-1/e^(1/10abs(-0.0555555555556pi - 26714619/51021164)) + 1 within a for loop.

I am getting the following error:

File "", line 1, in <module> File "/tmp/tmpkItECC/___code___.py", line 113, in <module> __temp=MuObject.calcValue((mu_enlacement[i])(**param_dict)) File "/tmp/tmpJuxeqk/___code___.py", line 97, in calcValue self._result[self._k,_sage_const_0 ]=R(self._value(theta_1=item[_sage_const_0 ],mu_t=item[_sage_const_1 ],mu_j=item[_sage_const_1 ])) File "parent.pyx", line 988, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7326) File "coerce_maps.pyx", line 156, in sage.structure.coerce_maps.NamedConvertMap._call_ (sage/structure/coerce_maps.c:4235)
File "expression.pyx", line 862, in sage.symbolic.expression.Expression._mpfr_ (sage/symbolic/expression.cpp:5117)
File "expression.pyx", line 796, in sage.symbolic.expression.Expression._eval_self (sage/symbolic/expression.cpp:4912) TypeError: Cannot evaluate symbolic expression to a numeric value.

If I copy paste the expression

print (-1/e^(1/10abs(-0.0555555555556pi - 26714619/51021164)) + 1).n()

to my notebook it evaluates fine to:

0.0674319647572598

I even tried to replace pi and e using a dictionary but I can't get it working.

Any ideas what i am doing wrong?

Thanks in advance,

Markus P.S.: I can make the notebook public if usefull

click to hide/show revision 2
fix display of Sage code

pi and e not evaluated when i use my own classes

This question might be related to this question: http://ask.sagemath.org/question/966/problem-with-sign-sgn-and-n

I have a symbolic calculation and I do evaluate it numerically. Within one of my classes (within my notebook; no external files) I evaluate this term

-1/e^(1/10abs(-0.0555555555556pi

-1/e^(1/10*abs(-0.0555555555556*pi - 26714619/51021164)) + 1
 

within a for loop.

I am getting the following error:

File "", line 1, in <module> File "/tmp/tmpkItECC/___code___.py", line 113, in <module> __temp=MuObject.calcValue((mu_enlacement[i])(**param_dict)) File "/tmp/tmpJuxeqk/___code___.py", line 97, in calcValue self._result[self._k,_sage_const_0 ]=R(self._value(theta_1=item[_sage_const_0 ],mu_t=item[_sage_const_1 ],mu_j=item[_sage_const_1 ])) File "parent.pyx", line 988, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7326) File "coerce_maps.pyx", line 156, in sage.structure.coerce_maps.NamedConvertMap._call_ (sage/structure/coerce_maps.c:4235)
File "expression.pyx", line 862, in sage.symbolic.expression.Expression._mpfr_ (sage/symbolic/expression.cpp:5117)
File "expression.pyx", line 796, in sage.symbolic.expression.Expression._eval_self (sage/symbolic/expression.cpp:4912) TypeError: Cannot evaluate symbolic expression to a numeric value.

If I copy paste the expression

print
  (-1/e^(1/10abs(-0.0555555555556pi -
  (-1/e^(1/10*abs(-0.0555555555556*pi - 26714619/51021164)) + 1).n()

1).n()

to my notebook it evaluates fine to:

0.0674319647572598

0.0674319647572598

I even tried to replace pi and e using a dictionary but I can't get it working.

Any ideas what i am doing wrong?

Thanks in advance,

Markus P.S.: I can make the notebook public if usefull