Comment #59 on issue 1598 by mattpap: New polynomials manipulation module
http://code.google.com/p/sympy/issues/detail?id=1598
There is actually quite a lot more you can do:
1. You can factor a polynomial over a non trivial domain:
In [1]: factor(x**2-2, extension=sqrt(2)+sqrt(3))
Out[1]:
⎛ ⎽⎽⎽⎞ ⎛ ⎽⎽⎽⎞
⎝x + ╲╱ 2 ⎠⋅⎝x - ╲╱ 2 ⎠
and you arrived with a result you could get in QQ(sqrt(2)). But you can
perform
formal factorization and see the difference:
In [2]: a = Symbol('alpha')
In [3]: factor(x**2-2, extension=AlgebraicNumber(sqrt(2)+sqrt(3), alias=a))
Out[3]:
⎛ 3⎞ ⎛ 3⎞
⎜ 9⋅α α ⎟ ⎜ 9⋅α α ⎟
⎜x + ─── - ──⎟⋅⎜x - ─── + ──⎟
⎝ 2 2 ⎠ ⎝ 2 2 ⎠
We obtained two linear factors in terms of sqrt(2)+sqrt(3) (alpha). This
can be
verified by substitution:
In [4]: (-a**3/2 + 9*a/2).subs(a, sqrt(2)+sqrt(3)).expand()
Out[4]:
⎽⎽⎽
-╲╱ 2
In [5]: (a**3/2 - 9*a/2).subs(a, sqrt(2)+sqrt(3)).expand()
Out[5]:
⎽⎽⎽
╲╱ 2
2. We can compute primitive elements of two or more extensions, e.g.:
In [6]: primitive_element(sqrt(2), sqrt(3))
Out[6]:
⎛ ⎽⎽⎽ ⎽⎽⎽⎞
⎝Poly(_x**4 - 10*_x**2 + 1, _x, domain='QQ'), ╲╱ 2 + ╲╱ 3 ⎠
3. We can compute a function with translates an algebraic field into
another field if
possible, e.g.:
In [7]: field_isomorphism(sqrt(2), sqrt(2)+sqrt(3))
Out[7]: [1/2, 0, -9/2, 0]
Which means QQ(sqrt(2)) and QQ(sqrt(2)+sqrt(3)) are isomorphic, the first
is a
subfield of the other, and we got explicit isomorphism as a side effect.
However,
QQ(sqrt(2)) is not isomorphic to QQ(sqrt(3)) (there is no way to express
sqrt(2) in
terms of sqrt(3)):
In [8]: field_isomorphism(sqrt(2), sqrt(3))
(the result is None).
In [9]: from sympy.polys.algebratools import QQ
Actually we can use __contains__ (in) to get a boolean result:
In [10]: sqrt(2) in QQ.algebraic_field(sqrt(2)+sqrt(3))
Out[10]: True
In [11]: 2+3*sqrt(3) in QQ.algebraic_field(sqrt(2)+sqrt(3))
Out[11]: True
In [12]: sqrt(2) in QQ.algebraic_field(sqrt(3))
Out[12]: False
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.