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

square roots don't simplify #13630

Open
Akuli opened this issue Nov 20, 2017 · 4 comments
Open

square roots don't simplify #13630

Akuli opened this issue Nov 20, 2017 · 4 comments
Labels

Comments

@Akuli
Copy link

Akuli commented Nov 20, 2017

Here's the problem.

>>> from sympy import *
>>> from sympy.abc import x
>>> a=(x**2 + x*sqrt(x**2 + 1) + 1)/(x + sqrt(x**2 + 1))
>>> b=sqrt(x**2+1)
>>> solveset(Eq(a,b),x)        # these are equal
S.Complexes
>>> simplify(b)
sqrt(x**2 + 1)
>>> simplify(a)     # but this does not simplify to b
(x**2 + x*sqrt(x**2 + 1) + 1)/(x + sqrt(x**2 + 1))
>>> 
@smichr
Copy link
Member

smichr commented Nov 21, 2017

[cps]

If we let x**2 + 1 be y then a can be rewritten as (y + x*sqrt(y))/(x + sqrt(y)); factoring sqrt(y) from the numerator gives sqrt(y) (and that's valid because sqrt(y)*sqrt(y) is always y). I suspect that modifying factor to handle this sort of situation would be the way to go. I wonder if the fact that minpoly(a) gives _x**2 - (x**2 + 1) is a clue that "y = x**2 + 1" is the change of variables that will make this simplification more apparent... just pondering.

@avirlrma
Copy link

We'll have to improvise on some of the subfuctions that simplfy uses. I would love to work on this , just need some guidance from the maintainers.

@sanyamg123
Copy link

I would like to work on this issue. Please guide me.

@thedoctar
Copy link

This may not be a problem with the simplify function in and of itself, because sp.simplify(a/sp.sqrt(x**2+1)) gives 1 for me.

So when you give a hint to simplify about the common factor, it can factorise.

Maybe if you use more sophisticated algorithms using ring theory, you could solve this. But it would inevitably involve the algorithm having to guess possible factors.

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

6 participants