Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trigsimp does not simplify test case #17802

Open
coxep opened this issue Oct 25, 2019 · 2 comments
Open

trigsimp does not simplify test case #17802

coxep opened this issue Oct 25, 2019 · 2 comments
Labels

Comments

@coxep
Copy link

coxep commented Oct 25, 2019

(Edited to actually demonstrate the issue)

I am running SymPy 1.4 in Python 2.7. I have confirmed that this issue is also present in SymPy Live Shell.

I have a simple trigonometric expression that I am trying to simplify:

from sympy import sin, cos, symbols, trigsimp
x_0, y_0, theta_0 = symbols("x_0 y_0 theta_0")
trigsimp((x_0*cos(2*theta_0) + x_0 + y_0*sin(2*theta_0))/(2*cos(theta_0)))

Expected simplification:
x_0 * cos(theta_0) + y_0 * sin(theta_0)

Actual simplification (no change):
(x_0 * cos(2 * theta_0) + x_0 + y_0 * sin(2 * theta_0)) / (2 * cos(theta_0))

@ethankward
Copy link
Contributor

I just tried this:

Python 2.7.12 (default, Oct  8 2019, 14:14:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sympy
>>> sympy.__version__
'1.4'
>>> from sympy import *
>>> from sympy.abc import x, y, theta
>>> trigsimp((x * cos(2 * theta) + x + y * sin(2 * theta)) / (2 * cos(theta)))
x*cos(theta) + y*sin(theta)

Any other details?

@coxep
Copy link
Author

coxep commented Oct 25, 2019

Oops, looks like I left an important piece out.

This works great:

from sympy import sin, cos, symbols, trigsimp
x_0, y_0, theta_0 = symbols("x0 y0 theta0")
trigsimp((x_0*cos(2*theta_0) + x_0 + y_0*sin(2*theta_0))/(2*cos(theta_0)))

This does not:

from sympy import sin, cos, symbols, trigsimp
x_0, y_0, theta_0 = symbols("x_0 y_0 theta_0")
trigsimp((x_0*cos(2*theta_0) + x_0 + y_0*sin(2*theta_0))/(2*cos(theta_0)))

The issue seems to occur when using underscores in string variable names, at least in this instance.

No issue here, though:

from sympy import sin, cos, symbols, trigsimp
x_0, y_0, theta_0 = symbols("x_0 y_0 theta_0")
trigsimp(x_0 * cos(theta_0) **2 + x_0 * sin(theta_0) ** 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants