Issue 3826 in sympy: trigsimp can't reverse tan double angle formula

2 views
Skip to first unread message

sy...@googlecode.com

unread,
May 15, 2013, 10:41:14 PM5/15/13
to sympy-...@googlegroups.com
Status: Valid
Owner: ----
Labels: Type-Defect Priority-Medium Simplify

New issue 3826 by asme...@gmail.com: trigsimp can't reverse tan double
angle formula
http://code.google.com/p/sympy/issues/detail?id=3826

In [71]: trigsimp(expand_trig(tan(2*x)))
Out[71]:
2⋅tan(x)
─────────────
2
- tan (x) + 1

I would have expceted tan(2*x)

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

sy...@googlecode.com

unread,
May 16, 2013, 12:04:57 PM5/16/13
to sympy-...@googlegroups.com

Comment #1 on issue 3826 by smi...@gmail.com: trigsimp can't reverse tan
a workaround is

>>> from sympy.simplify.fu import *
>>> eq
2*tan(x)/(-tan(x)**2 + 1)
>>> simplify(TR2(eq))

sy...@googlecode.com

unread,
May 17, 2013, 12:49:27 AM5/17/13
to sympy-...@googlegroups.com

Comment #2 on issue 3826 by smi...@gmail.com: trigsimp can't reverse tan
If something fails in trigsimp try the more robust fu.

>>> fu(tan(2*x).expand(trig=1))

sy...@googlecode.com

unread,
May 17, 2013, 2:56:20 PM5/17/13
to sympy-...@googlegroups.com

Comment #3 on issue 3826 by asme...@gmail.com: trigsimp can't reverse tan
What is the difference? Doesn't trigsimp call fu?

sy...@googlecode.com

unread,
May 21, 2013, 10:43:24 PM5/21/13
to sympy-...@googlegroups.com
Updates:
Status: Fixed

Comment #4 on issue 3826 by smi...@gmail.com: trigsimp can't reverse tan
No, fu is much more robust and slow. trigsimp just uses fu-functions to
mimic what the old trigsimp did previously. In any case, it has been
tweaked to recognize the double angle transformation.

sy...@googlecode.com

unread,
May 21, 2013, 11:51:09 PM5/21/13
to sympy-...@googlegroups.com

Comment #5 on issue 3826 by asme...@gmail.com: trigsimp can't reverse tan
How slow? The groebner algorithm is probably too slow to have on by
default, but unless fu is just as bad, I think it should be enabled by
default, especially if it is robust. Algorithms that aren't enabled by
default might as well not even exist for the vast majority of users,
because they will never bother to enable them. And furthermore, library
code in SymPy itself that calls trigsimp will not benefit (including
simplify()!), and it will be impossible for users to fix it.

Take heurisch as an example. It's ridiculously slow. In fact, if the
expression is just a little too big, it might take literally days to finish
(for all intents and purposes, it hangs). But it is also very powerful, and
before meijerg or full risch, it was all we had. In fact, it is able to
solve an integral that no other system can solve, and SymPy was for some
time listed on the Wikipedia article for the Risch algorithm because of
it. And even now there are a lot of integrals that SymPy can only do
because of it, even some very simple ones. If it were disabled by default,
SymPy would not be known for being able to do any integration, the code
would have gotten stale (no one would ever have found bugs in it and tried
to improve it), and there's even a decent chance that we would have never
made the jump to the more complete integration algorithms we have today.

sy...@googlecode.com

unread,
May 22, 2013, 10:58:46 AM5/22/13
to sympy-...@googlegroups.com

Comment #6 on issue 3826 by smi...@gmail.com: trigsimp can't reverse tan
It's not excruciatingly slow...this can be tested by changing futrig to fu
in the trigsimpfunc dictionary. One thing we could do is make fu the
default and hook futrig to a "quick" method (trigsimp(expr, method=quick)).

sy...@googlecode.com

unread,
May 22, 2013, 11:31:00 AM5/22/13
to sympy-...@googlegroups.com

Comment #7 on issue 3826 by asme...@gmail.com: trigsimp can't reverse tan
Let's try that.

sy...@googlecode.com

unread,
May 25, 2013, 5:48:04 PM5/25/13
to sympy-...@googlegroups.com

Comment #8 on issue 3826 by asme...@gmail.com: trigsimp can't reverse tan
Or better yet, if there is some heuristic that we can apply to functions
that we will know that there is not a chance that we will get a better
result from the full trigsimp, then just use the fast method. That way, it
will stay fast for already simple expressions, but will become powerful for
expressions that can be simplified a lot.

sy...@googlecode.com

unread,
May 26, 2013, 11:36:08 AM5/26/13
to sympy-...@googlegroups.com

Comment #9 on issue 3826 by smi...@gmail.com: trigsimp can't reverse tan
That's what I did. It's part of trigsimp now.
Reply all
Reply to author
Forward
0 new messages