Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
1

Solving polynomial equations with arbitrary coefficients

asked 10 years ago

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.

Preview: (hide)

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 ( 10 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 10 years ago

vdelecroix gravatar image

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

Preview: (hide)
link

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 ( 10 years ago )

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

rws gravatar imagerws ( 10 years ago )

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 ( 10 years ago )

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

tmonteil gravatar imagetmonteil ( 10 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

Stats

Asked: 10 years ago

Seen: 890 times

Last updated: Jan 19 '15