How can I simplify sqrt((n*n-19)*(x**3+x**2*y**5))/sqrt(x**3+x**2*y**5) ?

91 views
Skip to first unread message

hogehoge

unread,
Jul 31, 2016, 4:51:46 PM7/31/16
to sympy
I would like to reduction to common denominator in following case.

sqrt((n*n-19)*(x**3+x**2*y**5))/sqrt(x**3+x**2*y**5) ---> sqrt( n*n - 19 )
 

In [4]: sqrt((n*n-19)*(x**3+x**2*y**5))/sqrt(x**3+x**2*y**5)
Out[4]: 
   ________________________
  ╱ ⎛ 2     ⎞ ⎛ 3    2  5⎞ 
╲╱  ⎝n  - 19⎠⋅⎝x  + x ⋅y ⎠ 
───────────────────────────
         ____________      
        ╱  3    2  5       
      ╲╱  x  + x ⋅y        

In [5]: ratsimp(Out[4])
Out[5]: 
   _____________________________________
  ╱  2  3    2  2  5       3       2  5 
╲╱  n ⋅x  + n ⋅x ⋅y  - 19⋅x  - 19⋅x ⋅y  
────────────────────────────────────────
               ____________             
              ╱  3    2  5              
            ╲╱  x  + x ⋅y       


How can I simplify Out[4]?



In [8]: simplify(Out[4]*Out[4])
Out[8]: 
 2     
n  - 19


But I don't know How to reduction to common denominator in Out[4].
Could you tell me how to reduce to common denominator in Out[4]?

Aaron Meurer

unread,
Jul 31, 2016, 5:14:38 PM7/31/16
to sy...@googlegroups.com
SymPy isn't simplifying is because sqrt(x*y) isn't equal to
sqrt(x)*sqrt(y) in general (e.g., if x and y are negative).

You can force this simplification use expand_power_base(force=True):

In [12]: expand_power_base(sqrt((n*n-19)*(x**3+x**2*y**5))/sqrt(x**3+x**2*y**5),
force=True)
Out[12]:
_________
╱ 2
╲╱ n - 19

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/9747fec4-cad0-4083-9810-6d7450e7aaff%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

hogehoge

unread,
Aug 1, 2016, 3:46:02 AM8/1/16
to sympy
Thank you very much for your help!

2016年8月1日月曜日 6時14分38秒 UTC+9 Aaron Meurer:
Reply all
Reply to author
Forward
0 new messages