Ask Your Question
1

Solving polynomial equations with arbitrary coefficients

asked 2015-01-19 14:14:40 -0500

Phoenix gravatar image

This is my first time with Sage and no where on the documentation do I see how to solve a polynomial equation (say a quadratic) with arbitrary complex coefficients. Say I want to solve "x^2 - 7ax + (5+2I)" for x when a \in \mathbb{C}.

How does this happen?


I tried declaring "a" as a complex number using var('a', domain = CC) but that too didn't work. I am using ".factor()" to factorize.

edit retag flag offensive close merge delete

Comments

I'm not sure this is supported. Note that at least in some cases (maybe not yours) for some a there would only be one (double point) solution.

kcrisman gravatar imagekcrisman ( 2015-01-19 14:28:36 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-01-19 14:58:16 -0500

Hello,

Here is what I get

sage: a, x= var('a,x')
sage: p = x^2 - 7*a*x + 5+2*I
sage: (p == 0).solve([x])
[x == 7/2*a - 1/2*sqrt(49*a^2 - 8*I - 20), x == 7/2*a + 1/2*sqrt(49*a^2 - 8*I - 20)]

For the last step, note that you can also do

sage: solve(p == 0, [x])
[x == 7/2*a - 1/2*sqrt(49*a^2 - 8*I - 20), x == 7/2*a + 1/2*sqrt(49*a^2 - 8*I - 20)]

But you will not obtain this expression through factor (whose signification is somehow ambiguous).

Vincent

edit flag offensive delete link more

Comments

@Vincent Thanks! But is there anyway to make sage understand if "a" is an integer? Like the following doesn't work, m,k= var('m,k') and then saying w = exp( (2 pi *Im)/k); w^k . for $m$ being an integer, w^k = 1. But sage doesn't understand that.

Phoenix gravatar imagePhoenix ( 2015-01-19 22:00:57 -0500 )edit

Have you tried assume(a,'integer')?

rws gravatar imagerws ( 2015-01-20 03:24:27 -0500 )edit

There is no such feature called "assume". I am getting an error! Any way to declare a few variables as integers and then to do all the manipulations?

Phoenix gravatar imagePhoenix ( 2015-01-20 19:32:04 -0500 )edit

Which error did you get ? The assume function does exist.

tmonteil gravatar imagetmonteil ( 2015-01-21 03:32:41 -0500 )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

Stats

Asked: 2015-01-19 14:14:40 -0500

Seen: 233 times

Last updated: Jan 19 '15