1 | initial version |
Expanding on Snark's comment: use algebraic numbers to get an exact answer.
sage: R.<x> = QQbar['x']
sage: ff = x^3 - 2
sage: factor(ff)
(x - 1.259921049894873?) * (x + 0.6299605249474365? - 1.091123635971722?*I) * (x + 0.6299605249474365? + 1.091123635971722?*I)
sage: (1/ff).partial_fraction_decomposition()
(0,
[(0.2099868416491456? + 0.?e-19*I)/(x - 1.259921049894873?),
(-0.10499342082457277? + 0.1818539393286203?*I)/(x + 0.6299605249474365? - 1.091123635971722?*I),
(-0.10499342082457277? - 0.1818539393286203?*I)/(x + 0.6299605249474365? + 1.091123635971722?*I)])
2 | more on extracting coefficients of factorization and of partial fraction decomposition |
Expanding on Snark's comment: use algebraic numbers to get an exact answer.
sage: R.<x> = QQbar['x']
sage: ff = x^3 - 2
sage: factor(ff)
(x - 1.259921049894873?) * (x + 0.6299605249474365? - 1.091123635971722?*I) * (x + 0.6299605249474365? + 1.091123635971722?*I)
sage: (1/ff).partial_fraction_decomposition()
(0,
[(0.2099868416491456? + 0.?e-19*I)/(x - 1.259921049894873?),
(-0.10499342082457277? + 0.1818539393286203?*I)/(x + 0.6299605249474365? - 1.091123635971722?*I),
(-0.10499342082457277? - 0.1818539393286203?*I)/(x + 0.6299605249474365? + 1.091123635971722?*I)])
The entries are exact; they live in QQbar
. To access the entries:
sage: for q in factor(ff):
... q = q[0]
... print 'x - a =', q
... a = QQbar(x - q)
... print ' a =', a
... print ' minpoly:', a.minpoly()
x - a = x - 1.259921049894873?
a = 1.259921049894873?
minpoly: x^3 - 2
x - a = x + 0.6299605249474365? - 1.091123635971722?*I
a = -0.6299605249474365? + 1.091123635971722?*I
minpoly: x^3 - 2
x - a = x + 0.6299605249474365? + 1.091123635971722?*I
a = -0.6299605249474365? - 1.091123635971722?*I
minpoly: x^3 - 2
and
sage: for q in (1/ff).partial_fraction_decomposition()[1]:
... print 'a / (x - b) =', q
... a = QQbar(q.numerator())
... print ' a =', a
... print ' minpoly:', a.minpoly()
... b = QQbar(x - q.denominator())
... print ' b =', b
... print ' minpoly:', b.minpoly()
a / (x - b) = (0.2099868416491456? + 0.?e-19*I)/(x - 1.259921049894873?)
a = 0.2099868416491456? + 0.?e-19*I
minpoly: x^3 - 1/108
b = 1.259921049894873?
minpoly: x^3 - 2
a / (x - b) = (-0.10499342082457277? + 0.1818539393286203?*I)/(x + 0.6299605249474365? - 1.091123635971722?*I)
a = -0.10499342082457277? + 0.1818539393286203?*I
minpoly: x^3 - 1/108
b = -0.6299605249474365? + 1.091123635971722?*I
minpoly: x^3 - 2
a / (x - b) = (-0.10499342082457277? - 0.1818539393286203?*I)/(x + 0.6299605249474365? + 1.091123635971722?*I)
a = -0.10499342082457277? - 0.1818539393286203?*I
minpoly: x^3 - 1/108
b = -0.6299605249474365? - 1.091123635971722?*I
minpoly: x^3 - 2
3 | No.3 Revision |
Expanding on Snark's comment: use algebraic numbers to get an exact answer.
Algebraic numbers can be explored, you can ask their minimal polynomial or a radical expression.
sage: R.<x> = QQbar['x']
sage: ff = x^3 - 2
sage: factor(ff)
(x - 1.259921049894873?) * (x + 0.6299605249474365? - 1.091123635971722?*I) * (x + 0.6299605249474365? + 1.091123635971722?*I)
sage: (1/ff).partial_fraction_decomposition()
(0,
[(0.2099868416491456? + 0.?e-19*I)/(x - 1.259921049894873?),
(-0.10499342082457277? + 0.1818539393286203?*I)/(x + 0.6299605249474365? - 1.091123635971722?*I),
(-0.10499342082457277? - 0.1818539393286203?*I)/(x + 0.6299605249474365? + 1.091123635971722?*I)])
The entries are exact; they live in QQbar
. To access investigate the entries:
sage: for q in factor(ff):
... ....: q = q[0]
... ....: print 'x - a =', q
... ....: a = QQbar(x - q)
... ....: print ' a =', a
... ....: print ' minpoly:', a.minpoly()
....: print ' radical:', a.radical_expression()
....:
x - a = x - 1.259921049894873?
a = 1.259921049894873?
minpoly: x^3 - 2
radical: 2^(1/3)
x - a = x + 0.6299605249474365? - 1.091123635971722?*I
a = -0.6299605249474365? + 1.091123635971722?*I
minpoly: x^3 - 2
radical: 1/2*I*sqrt(3)*2^(1/3) - 1/2*2^(1/3)
x - a = x + 0.6299605249474365? + 1.091123635971722?*I
a = -0.6299605249474365? - 1.091123635971722?*I
minpoly: x^3 - 2
radical: -1/2*I*sqrt(3)*2^(1/3) - 1/2*2^(1/3)
and
sage: for q in (1/ff).partial_fraction_decomposition()[1]:
... ....: print 'a / (x - b) =', q
... ....: a = QQbar(q.numerator())
... ....: print ' a =', a
... ....: print ' minpoly:', a.minpoly()
... ....: print ' radical:', a.radical_expression()
....: b = QQbar(x - q.denominator())
... ....: print ' b =', b
... ....: print ' minpoly:', b.minpoly()
....: print ' radical:', b.radical_expression()
....:
a / (x - b) = (0.2099868416491456? + 0.?e-19*I)/(x 0.2099868416491456?/(x - 1.259921049894873?)
a = 0.2099868416491456? + 0.?e-19*I
0.2099868416491456?
minpoly: x^3 - 1/108
radical: 1/12*4^(2/3)
b = 1.259921049894873?
minpoly: x^3 - 2
radical: 2^(1/3)
a / (x - b) = (-0.10499342082457277? + 0.1818539393286203?*I)/(x + 0.6299605249474365? - 1.091123635971722?*I)
a = -0.10499342082457277? + 0.1818539393286203?*I
minpoly: x^3 - 1/108
radical: 1/24*4^(2/3)*(I*sqrt(3) - 1)
b = -0.6299605249474365? + 1.091123635971722?*I
minpoly: x^3 - 2
radical: 1/2*I*sqrt(3)*2^(1/3) - 1/2*2^(1/3)
a / (x - b) = (-0.10499342082457277? - 0.1818539393286203?*I)/(x + 0.6299605249474365? + 1.091123635971722?*I)
a = -0.10499342082457277? - 0.1818539393286203?*I
minpoly: x^3 - 1/108
radical: 1/24*4^(2/3)*(-I*sqrt(3) - 1)
b = -0.6299605249474365? - 1.091123635971722?*I
minpoly: x^3 - 2
radical: -1/2*I*sqrt(3)*2^(1/3) - 1/2*2^(1/3)