real_root and rewriting #27731
-
I'm currently stuck on this seemingly simple problem when using SymPy: >>> real_root(cbrt(-2))
3 ___
-╲╱ 2
>>> real_root(1/cbrt(-2))
2/3
-(-2)
─────────
2 Note how >>> 1/cbrt(-2)
2/3
-(-2)
─────────
2 Is there any way to extract the minus sign from the second expression? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The docstring says: How would you define in general the behaviour that you expect here? The input is some complex number and you want a real number that is a different root of the same polynomial? Something like: In [11]: [r for r in roots(minpoly(1/cbrt(-2))) if r.is_real]
Out[11]:
⎡ 2/3 ⎤
⎢-2 ⎥
⎢──────⎥
⎣ 2 ⎦ In general it is probably better to use |
Beta Was this translation helpful? Give feedback.
The docstring says:
This will only create a real root of a principal root.
How would you define in general the behaviour that you expect here? The input is some complex number and you want a real number that is a different root of the same polynomial?
Something like:
In general it is probably better to use
1 / real_root(-2, 3)
in the first place because I'm not sure how this is well defined if starting from arbitrary complex numbers.