Last week I spent most of my time writing and testing new trigonometric functions for Sympy. Sympy already had sin, cos, tan, cot, asin, acos, atan, acot, but did not have sec, csc, asec, or acsc. So I added those four new functions and am in the process of writing very extensive tests for them.
The reason for writing these new functions is so that the trig functions have the same behavior as the ones in Mathematica. There are a few things that Mathematica does that is very nice, one of them being that any arguments that have a pi shift (as in sin(a + b*pi)), will always return another trig function whose pi shift is within the interval between 0 and pi/4. For example,
-cos(pi/8)
>>> x = Symbol(‘x’)
>>> sin(x + 11*pi/8)
-cos(-x + pi/8)
>>> sin(acot(x))
1/(x*(1 + x**(-2))**(1/2))
>>> sin(pi/10)
-1/4 + 5**(1/2)/4
Getting all the behavior to work with the inverse trig functions is also implemented, as well as the special values of the trig functions for arguments which are integer multiples of pi/10. The next task is going to be to get all of this code working with the rest of Sympy so it can be put into place.
This behavior is essential to making the trigonometric simplification routine in Sympy to be more capable, and will greatly benefit both Sympy and PyDy.
Is there a reason that sin(arccot(x)) returns 1/(x*sqrt(1+1/x^2)) instead of 1/sqrt(1+x^2). That is what Maple returns for me. I realize that the two are only equal when x is positive, but Maple plots of sin(arccot(x)), 1/(x*sqrt(1+1/x^2)), and 1/sqrt(1+x^2) reveal that sin(arccot(x)) == 1/sqrt(1+x^2) (the other one is negative for negative x).
I don’t know much about how these need to be handled so that they remain valid for complex x, but a simple right triangle tells me that sin(arccot(x)) should be 1/sqrt(x**2 + 1)
The reason is because I programmed it based off what Wolfram Alpha returns:
http://www53.wolframalpha.com/input/?i=sin(arccot(x))
The rationale for returning this result is that it is valid for all real x, positive or negative. I believe it is also valid for complex x as well.
I think with Fabian’s assumption system, Sympy will be able to convert 1/(x*sqrt(1+1/x**2)) to 1/sqrt(1+x**2) for x>0, but I don’t think this should be programmed into the trig functions themselves.