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

Identifies true equation as FALSE #66

Open
theauditor opened this issue Oct 3, 2015 · 8 comments
Open

Identifies true equation as FALSE #66

theauditor opened this issue Oct 3, 2015 · 8 comments

Comments

@theauditor
Copy link

The following equation returns 'False'
Equation : ((sin(x) - cos(x))(sin(x) + cos(x))) == (1 - 2 (cos(x)**2))

How ever individually the RHS and LHS produce the right results
(1 - 2 (cos(x)**2)) = -cos(2x)
((sin(x) - cos(x))(sin(x) + cos(x))) = -cos(2x)

@aktech
Copy link
Member

aktech commented Oct 3, 2015

This is correct. The == is used for structural comparison, not mathematical. http://docs.sympy.org/latest/tutorial/gotchas.html#equals-signs

@theauditor
Copy link
Author

Hmmm. Works but not at all intuitive. Feels like it should have been solved with a simple operator. Doesn't feel right :(

@ashutoshsaboo
Copy link
Contributor

@aktech @asmeurer @certik @hargup . How about if we change the structural comparison == to mathematical comparison just for SymPy Gamma? As, in we can modify the input of the user (using simple string manipulation) to simplify(a-b)==0 or a.equals(b) and then pass it ahead to the SymPy functions, for evaluating the modified result?

Details about this described here - https://groups.google.com/d/msg/sympy/kiCMquuqC2s/q9RVhPC8AAAJ .

Any opinions on this?

@asmeurer
Copy link
Member

Yes, I agree that for SymPy Gamma == should be more mathematical. It also could mean "solve", as in, if someone writes x^2 - 1 = 0, they probably want to solve for x. So = (and ==) should have a card for determining of the two sides are equal, and for solving the equation.

@asmeurer
Copy link
Member

It's obviously impossible to do this perfectly, but in general, SymPy Gamma should aim to do what the user expects it to do, and work around some of the idiosyncrasies of SymPy the library.

@ashutoshsaboo
Copy link
Contributor

@asmeurer Yes exactly I agree with you. I'll try mapping the == in SymPy Gamma to a.equals(b) and then correspondingly calling the solve() function as well.

But what would you suggest would be better the simplify(a-b)==0 or a.equals(b)? AFAIK, a.equals(b) must be much more efficient and less in complexity than simplify(a-b)==0?

@asmeurer
Copy link
Member

I think equals is fine.

@ashutoshsaboo
Copy link
Contributor

@asmeurer Please review PR #75 ! Thanks! 😃

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

No branches or pull requests

4 participants