On Mon, Jun 22, 2009 at 5:49 PM, Luke<[email protected]> wrote: > > Ondrej and I have had some discussion about what the trigonometric > functions tan, cot, sec, csc should return at singular points. It > seems there are a couple of options: > 1) Return S.ComplexInfinity for things like tan(pi/2), tan(-pi/2), > tanh(pi/2*I), tanh(-pi/2*I), etc. > 2) Raise an exception of some sort. > > Mathematica returns ComplexInfinity for all the examples mentioned in > 1) above. What do people think about this? I'd like to see what > people think would be the right choice. An interesting subtlety of > this is that in sympy, currently things like S(1)/S(0) return oo > (Infinity). By this rationale, tan(pi/2) = sin(pi/2)/cos(pi/2) = 1/0 > = oo (Infinity), but this doesn't seem the right approach.
Indeed: In [1]: 1/0 --------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last) /home/ondrej/repos/sympy/<ipython console> in <module>() ZeroDivisionError: float division In [2]: S(1)/0 Out[2]: ∞ Btw, so does wolframalpha: http://www.wolframalpha.com/input/?i=1%2F0 > > If an exception should be raised, what kind? ZeroDivisionError? > PoleError (not sure what this really is, but Ondrej suggested it)? $ git grep PoleError sympy/core/__init__.py: Function, expand, PoleError sympy/core/function.py:class PoleError(Exception): sympy/core/function.py: raise PoleError("Cannot expand around %s" % ( sympy/series/limits.py:from sympy.core import S, Add, sympify, Basic, PoleError, sympy/series/limits.py: except PoleError: sympy/series/limits.py: raise PoleError(msg % (e, z, z0, dir)) sympy/series/tests/test_nseries.py: PoleError, floor, ceiling, raises, as sympy/series/tests/test_nseries.py: raises(PoleError, "sin(1/x).series(x, 0, sympy/series/tests/test_nseries.py: raises(PoleError, "sin(1+1/x).series(x, 0 sympy/series/tests/test_nseries.py: raises(PoleError, "(x*sin(1/x)).series(x, > > Whatever the consensus, I just want to make the trig functions all consistent. Indeed, I would be interested to get some input from other people too, before we make some decision. Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" 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?hl=en -~----------~----~----~----~------~----~------~--~---
