Ask Your Question
1

Multiplying Roots of a Polynomial

asked 2019-01-17 12:29:29 +0100

LukeC93 gravatar image

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

I have a polynomial $f = x^{2}((x+\frac{1}{x})^{2} - 1) $. I would like to be able to do to things:

1) See $f$ in the form $\beta(x - \alpha_1)(x-\alpha_2)(x-\alpha_3)(x-\alpha_4)$

2) Know the value of $\beta (\prod_i \alpha_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!

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2019-01-23 19:24:03 +0100

BrentBaccala gravatar image

updated 2019-01-23 19:24:52 +0100

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
edit flag offensive delete link more
0

answered 2019-01-17 18:03:43 +0100

rburing gravatar image

updated 2019-01-17 18:11:42 +0100

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)^n f_0$ where $n = \deg(f)$ and $f_0$ 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
edit flag offensive delete link more
0

answered 2019-01-17 22:18:49 +0100

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...

edit flag offensive delete link more

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 ( 2019-01-17 23:39:49 +0100 )edit

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

LukeC93 gravatar imageLukeC93 ( 2019-01-18 10:11:45 +0100 )edit

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

rburing gravatar imagerburing ( 2019-01-18 10:36:23 +0100 )edit

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: 2019-01-17 12:29:29 +0100

Seen: 605 times

Last updated: Jan 23 '19