1 | initial version |
If you don't know the roots, you can use H.roots()
. For example:
sage: H=2*(x+5)**2-4
sage: H.roots()
[(-sqrt(2) - 5, 1), (sqrt(2) - 5, 1)]
sage: prod((x-_[0]) for _ in H.roots())
(x - sqrt(2) + 5)*(x + sqrt(2) + 5)
2 | No.2 Revision |
If you don't know the roots, you can use H.roots()
. For example:
sage: H=2*(x+5)**2-4
sage: H.roots()
[(-sqrt(2) - 5, 1), (sqrt(2) - 5, 1)]
sage: prod((x-_[0]) for _ in H.roots())
(x - sqrt(2) + 5)*(x + sqrt(2) + 5)
Note that this has leading coefficient 1, not 2, so it's not equal to H
. This could be repaired by multiplying by
sage: H.simplify_full().leading_coefficient(x)
2
3 | No.3 Revision |
If you don't know the roots, you can use H.roots()
. For example:
sage: H=2*(x+5)**2-4
sage: H.roots()
[(-sqrt(2) - 5, 1), (sqrt(2) - 5, 1)]
sage: prod((x-_[0]) prod((x-_[0])^_[1] for _ in H.roots())
(x - sqrt(2) + 5)*(x + sqrt(2) + 5)
Note that this has leading coefficient 1, not 2, so it's not equal to H
. This could be repaired by multiplying by
sage: H.simplify_full().leading_coefficient(x)
2