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

ratsimp does not work when these is a root in the numerator #15969

Open
homocomputeris opened this issue Feb 12, 2019 · 8 comments
Open

ratsimp does not work when these is a root in the numerator #15969

homocomputeris opened this issue Feb 12, 2019 · 8 comments
Labels

Comments

@homocomputeris
Copy link

homocomputeris commented Feb 12, 2019

from sympy import *
ratsimp(sqrt(15)/180 + S(1)/18)       

gives
Out[10]: sqrt(15)/180 + 1/18
not
(sqrt(15)+10)/180

sympy master branch at c267d55

@oscargus
Copy link
Contributor

I can confirm this, but even when changing the code to return what you expects it gets simplified...

In [42]: (sqrt(15)+10)/180
Out[42]: 

image

@RituRajSingh878
Copy link
Contributor

many types of expression are failing -

In [4]: from sympy import * 
   ...: ratsimp(log(2)/180 + S(1)/18)                                                                                                                                                                        
Out[4]: 
log(2)   1 
────── + ──
 180     18

In [5]: from sympy import * 
   ...: ratsimp(exp(2)/180 + S(1)/18)                                                                                                                                                                        
Out[5]: 
  2     
 ℯ    1 
─── + ──
180   18

In [6]: from sympy import * 
   ...: ratsimp(I/180 + S(1)/18)                                                                                                                                                                             
Out[6]: 
1     ⅈ 
── + ───
18   180


@RituRajSingh878
Copy link
Contributor

ratsimp is -"Put an expression over a common denominator, cancel and reduce."
So after canceling and reducing, it may not have a common base.

@homocomputeris
Copy link
Author

ratsimp is -"Put an expression over a common denominator, cancel and reduce."
So after canceling and reducing, it may not have a common base.

But it doesn't imply it is split back into some sum:
Reduce a Fraction: Simplify. That is, cancel out all common factors in the numerator and denominator until no common factors remain.

I believe, if ratsimp is explicitly applied, then it should always return a fraction over a common denominator, which probably should be its main purpose. Probably, expand should be the opposite of ratsimp.

@oscargus
Copy link
Contributor

I also think that it ideally should keep everything with a single denominator. Not obvious where it is changed back though...

@mpjuers
Copy link

mpjuers commented Feb 17, 2019

Does anyone know of a workaround for this?

@jksuom
Copy link
Member

jksuom commented Feb 18, 2019

You could try changing return f/g in ratsimp to return Mul(f, 1/g, evaluate=False).

@RituRajSingh878
Copy link
Contributor

Due to this many test case were failing.

You could try changing return f/g in ratsimp to return Mul(f, 1/g, evaluate=False).

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