On 05/19/2014 08:13:46 PM, Aaron Meurer wrote:
In this case, there is a simplification function that will do it,
sqrtdenest:
In [3]: sqrtdenest(foo)
Out[3]: 2
Thanks. I can use that in a number of places!
In general, there is no single algorithm for simplification (indeed,
it's not even an easy concept to define), but simplify() tries to do
its best. The more you know about the steps that are required to do
the simplification you want, or the type of expression you have, the
better you can apply individual simplification functions to get what
you want.
In this case, though, I would consider it a bug that simplify() did
not try sqrtdenest.
Aaron Meurer
On Mon, May 19, 2014 at 3:54 PM, Mike Witt <[email protected]> wrote:
> Is it typical to have to "fiddle around" with different
> forms of an expression to get it to simplify? For example:
>
> In [7]: from sympy import sqrt
>
> In [8]: foo=-sqrt(-2*sqrt(2)+3)+sqrt(2*sqrt(2)+3)
>
> In [9]: print foo
> -sqrt(-2*sqrt(2) + 3) + sqrt(2*sqrt(2) + 3)
>
> In [10]: print foo.simplify()
> -sqrt(-2*sqrt(2) + 3) + sqrt(2*sqrt(2) + 3)
>
> In [11]: print (foo**2).expand()
> -2*sqrt(-2*sqrt(2) + 3)*sqrt(2*sqrt(2) + 3) + 6
>
> In [12]: print (foo**2).expand().simplify()
> 4
>
> Or is there some kind of "general strategy" that will
> always work (assuming there is clearly a simplification
> possible, like an integer as above)?
>
> -Mike
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/1400536494.2532.18%40Vector.
> For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAKgW%3D6LKVAZ5OT-z%2B_asPcLB97wU2GmtqNRxT1ws2Ga9779XuQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/1400556929.2532.20%40Vector.
For more options, visit https://groups.google.com/d/optout.