Processing math: 100%
Ask Your Question
1

Multiplying Roots of a Polynomial

asked 6 years ago

LukeC93 gravatar image

Hello - I'm new to SAGE, so trying to get to grips with the basics!

I have a polynomial f=x2((x+1x)21). I would like to be able to do to things:

1) See f in the form β(xα1)(xα2)(xα3)(xα4)

2) Know the value of β(iαi)

Using

f.factor

f.roots

Does not give me the linear factorisation, nor can I see a simple way of getting the product of the roots.

In the long term I'm hoping to do this for polynomials of larger degree, so any advice would be great!

Preview: (hide)

3 Answers

Sort by » oldest newest most voted
1

answered 6 years ago

BrentBaccala gravatar image

updated 6 years ago

You can also get exact results by using the Algebraic Field QQbar, which avoids the need of manually constructing a splitting field (like rburing shows in his answer).

In Sage 8.4, I'd also suggest setting QQbar's display option to radical instead of decimal (the default). Try both and see the difference; it's the simplest way I know how to explain it!

sage: QQbar.options.display_format = 'radical'
sage: R.<x> = PolynomialRing(QQbar)
sage: f = x^2*((x+1/x)^2-1)
sage: f.factor()
(x - 1/2*I*sqrt(3) - 1/2) * (x + 1/2*I*sqrt(3) - 1/2) * (x - 1/2*I*sqrt(3) + 1/2) * (x + 1/2*I*sqrt(3) + 1/2)
sage: mul([p.constant_coefficient() for p,m in f.factor()])
1
Preview: (hide)
link
0

answered 6 years ago

rburing gravatar image

updated 6 years ago

Do you want exact results or approximations? For exact results, you can define

R.<x> = PolynomialRing(QQ)
f = R(x^2*((x+1/x)^2-1))
K.<a> = f.splitting_field()

so you can do:

sage: f.change_ring(K).factor()
(x - a) * (x + a - 1) * (x - a + 1) * (x + a)
sage: f.change_ring(K).roots()
[(a, 1), (-a + 1, 1), (a - 1, 1), (-a, 1)]
sage: beta = f.leading_coefficient()
sage: myprod = beta*prod(r[0]^r[1] for r in f.change_ring(K).roots()); myprod
1

By Vieta's formulas what you get is just (1)nf0 where n=deg(f) and f0 is the constant coefficient of f.

sage: myprod == (-1)^f.degree()*f.constant_coefficient()
True

If you are wondering what a is in the discussion above: it is a root of

sage: a.minpoly()
x^2 - x + 1

As for numerics, you can do e.g.:

sage: f.change_ring(QQbar).roots()
[(-0.500000000000000? - 0.866025403784439?*I, 1),
(-0.500000000000000? + 0.866025403784439?*I, 1),
 (0.500000000000000? - 0.866025403784439?*I, 1),
 (0.500000000000000? + 0.866025403784439?*I, 1)]
sage: beta*prod(r[0]^r[1] for r in f.change_ring(QQbar).roots())
1.000000000000000? + 0.?e-18*I
Preview: (hide)
link
0

answered 6 years ago

Emmanuel Charpentier gravatar image

Let's see...

sage: f=x^2*((x+1/x)^2-1)

The roots are :

sage: f.roots(multiplicities=False)
[-sqrt(1/2*I*sqrt(3) - 1/2),
 sqrt(1/2*I*sqrt(3) - 1/2),
 -sqrt(-1/2*I*sqrt(3) - 1/2),
 sqrt(-1/2*I*sqrt(3) - 1/2)]

Therefore, the factorized polynom is :

sage: prod([x-u for u in f.roots(multiplicities=False)])
(x + sqrt(1/2*I*sqrt(3) - 1/2))*(x - sqrt(1/2*I*sqrt(3) - 1/2))*(x + sqrt(-1/2*I*sqrt(3) - 1/2))*(x - sqrt(-1/2*I*sqrt(3) - 1/2))

And the roots' products is:

sage: prod(f.roots(multiplicities=False)).expand()
1

Whereas moving to a polynomial ring, more specialized, is often useful, it is not necessary here...

Preview: (hide)
link

Comments

I would argue polynomial rings are simpler than the symbolic ring. It depends on your point of view. In any case, it is good to see both approaches.

rburing gravatar imagerburing ( 6 years ago )

Thank you - this is perfect for what I'm after!

LukeC93 gravatar imageLukeC93 ( 6 years ago )

For fun, you can check what happens for f = x^5 - x - 1 in both answers.

rburing gravatar imagerburing ( 6 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 6 years ago

Seen: 697 times

Last updated: Jan 23 '19