You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not familiar with the implementation of trigsimp, so instead of making a PR I'll propose two additions that could be possibly useful (and that aren't performed by any of the available options for the method parameter).
First, an arguably common assumption (that can be useful for symbolic analysis) is that:
For comparison, calling simplify(asin(sin(alpha)), inverse=True) ignores possible set problems and returns alpha, as explained on the docs. This inverse parameter is not available on trigsimp (no internal call to inversecombine), and calling simplify(atan2(sin(alpha), cos(alpha)), inverse=True) does not return alpha as could be expected.
This could be implemented, for example, as:
def simp1(theta):
if type(theta) is not sp.atan2:
return theta
b, a = theta.args
if type(b) == sp.sin and type(a) == sp.cos and b.args[0] == a.args[0]:
return a.args[0]
elif type(b) == sp.cos and type(a) == sp.sin and b.args[0] == a.args[0]:
return sp.pi/2 - a.args[0]
else:
return theta
The following full table of relationships could also be implemented:
Second, consider the symbolic expression $\theta = \operatorname{atan_{2}}(b, a)$
When $|b| = |a|$, the expression can be simplified to: $\theta = \operatorname{atan_{2}}(\operatorname{sign}(b), \operatorname{sign}(a))$ which has only 4 possible values:
def simp2(theta):
if type(theta) is not sp.atan2:
return theta
b, a = theta.args
if sp.Abs(a) == sp.Abs(b):
return sp.sign(b)*(2 - sp.sign(a))*sp.pi/4
else:
return theta
The text was updated successfully, but these errors were encountered:
evbernardes
changed the title
Add atan2(b, a) simplifications to sympy.simplify.trigsimp.trigsimp
Add atan2 simplifications to simplify and trigsimp
Dec 15, 2022
Indeed! I imagine though that a simpler x can be more useful for someone using this kind of simplifications, and it would be consistent with the current effect of inversecombine on trigonometric functions.
I'm not familiar with the implementation of
trigsimp
, so instead of making a PR I'll propose two additions that could be possibly useful (and that aren't performed by any of the available options for themethod
parameter).First, an arguably common assumption (that can be useful for symbolic analysis) is that:
Which also gives:
For comparison, calling
simplify(asin(sin(alpha)), inverse=True)
ignores possible set problems and returnsalpha
, as explained on the docs. Thisinverse
parameter is not available ontrigsimp
(no internal call toinversecombine
), and callingsimplify(atan2(sin(alpha), cos(alpha)), inverse=True)
does not returnalpha
as could be expected.This could be implemented, for example, as:
The following full table of relationships could also be implemented:
Second, consider the symbolic expression$\theta = \operatorname{atan_{2}}(b, a)$
When$|b| = |a|$ , the expression can be simplified to: $\theta = \operatorname{atan_{2}}(\operatorname{sign}(b), \operatorname{sign}(a))$ which has only 4 possible values:
This can be reduced to the following formula:
Which can be implemented, for example, as:
The text was updated successfully, but these errors were encountered: