On Sat, Apr 4, 2015 at 7:15 AM, Paul Royik <
distan...@gmail.com> wrote:
> Hwow can I make sympy factor x+sqrt(x)-2 into (sqrt(x)+1)(sqrt(x)-2) ?
These two are not equal, are they?
In [15]: (sqrt(x)+1)*(sqrt(x)-2)
Out[15]: (√x - 2)⋅(√x + 1)
In [16]: expand(_)
Out[16]: -√x + x - 2
I think you got the minus wrong in the sqrt(x) term in x-sqrt(x)-2.
Anyway, to factor it, I would do:
In [1]: x = Symbol("x", positive=True)
In [2]: e = x-sqrt(x)-2
In [3]: factor(e.subs(x, x**2)).subs(x, sqrt(x))
Out[3]: (√x - 2)⋅(√x + 1)
In [4]: e = x+sqrt(x)-2
In [5]: factor(e.subs(x, x**2)).subs(x, sqrt(x))
Out[5]: (√x - 1)⋅(√x + 2)
Ondrej
>
> --
> 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
http://groups.google.com/group/sympy.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/sympy/3ca41d24-8764-4f03-9a0a-d327893e15c7%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.