Comment #13 on issue 1321 by [email protected]: trigonometric
functions of floating-point numbers should return floating-point numbers
http://code.google.com/p/sympy/issues/detail?id=1321
Another update:
New code is being pushed to https://github.com/ness01/sympy/tree/1321_trig
core/tests/test_function, test_evalf_default illustrates the new behaviour:
assert type(sin(4.0)) == Real
assert type(re(sin(I + 1.0))) == Real
assert type(im(sin(I + 1.0))) == Real
assert type(sin(4)) == sin
assert type(sin(Rational(1,4))) == sin
Problems:
0) solve(sin(x) - 0.5,x) fails because solve(x-0.5, x) fails. I have been
informed this was fixed somewhere else.
1) test_floats in core/test/test_match fails.
This is pretty much expected. What is less expected is that passing
evaluate=False does not fix the issue. Consider:
a,b = map(Wild, 'ab')
e = cos(0.12345, evaluate=False)**2
r = e.match(a*cos(b)**2)
r[a]
2
1.0153960867755â‹…cos (0.12345)
simplify(r[a])
1
r[b]
0.123450000000000
Since I don't know what the expected behaviour is, I cannot do a lot here.
Aside: I should mention that there is a small change in core/cache.py. I
added the types of the arguments to the object that is being hashed. This
is because otherwise sin(4) and sin(4.0) end up in the same cache entry.
I.e. without this change we have the following:
sin(4)
sin(4)
sin(4.0)
sin(4)
and
sin(4.0)
-0.75...
sin(4)
-0.75...
whereas the expected is
sin(4.0)
-0.75...
sin(4)
sin(4)
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
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/sympy-issues?hl=en.