Status: Accepted
Owner: ----
Labels: Type-Defect Priority-Low
New issue 2972 by someb...@bluewin.ch: Autoevaluation of functions for
floats and complex floats
http://code.google.com/p/sympy/issues/detail?id=2972
Consider the following list of numbers:
In [2]: vals = [2, 2.0, 2j, 2.0j, 2+2j, 2.0+2.0j, 2.0+2j, 2+2.0j]
some are integers ("numbers w/o a ."), some floats ("numbers w/ a .") and
some mixed.
Now let's see what happens to different functions that get called with
these arguments:
In [7]: [ sqrt(i) for i in vals ]
Out[7]: [sqrt(2),
1.41421356237310,
1.4142135623731*(-1)**(1/4),
1.4142135623731*(-1)**(1/4),
sqrt(2.0 + 2.0*I),
sqrt(2.0 + 2.0*I),
sqrt(2.0 + 2.0*I),
sqrt(2.0 + 2.0*I)]
This autoevals for floats and pure complex floats, but not for complex ints
and mixed.
In [4]: [ sin(i) for i in vals ]
Out[4]:
[sin(2),
0.909297426825682,
3.62686040784702*I,
3.62686040784702*I,
3.42095486111701 - 1.50930648532362*I,
3.42095486111701 - 1.50930648532362*I,
3.42095486111701 - 1.50930648532362*I,
3.42095486111701 - 1.50930648532362*I]
Here we autoeval for all but pure real ints.
In [3]: [ erf(i) for i in vals ]
Out[3]: [erf(2),
0.995322265018953,
erf(2.0*I),
erf(2.0*I),
1.15131086639807 + 0.127291629463141*I,
1.15131086639807 + 0.127291629463141*I,
1.15131086639807 + 0.127291629463141*I,
1.15131086639807 + 0.127291629463141*I]
Here it becomes even more difficult to tell what happens ...
I'd suggest that a (special) function always auto evaluates
for floats and complex floats but never for ints and complex ints.
Then we have the question of which type the expression "2+1.0j" is.
Probably it should be a complex float equal to "2.0+2.0j".
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.