On Apr 15, 2009, at 3:34 AM, Diravan wrote:

>
> I need to solve a very simple equation x^2 + 1 = 0 and I don't want
> any complex solutions.
> I tried this
> x = var('x')
> assume(x,'real')
> solve(x^2 + 1 == 0)
> but the output is [x == -1*I, x == I]
> Does exist any solution in order to avoid this ?


I think the assume commands are mostly used for simplification.

A quadratic equation has at most two roots (ignoring multiplicity)  
and since you have two non-real roots, that means there are no real  
roots. If you are interested in finding the real roots of a  
polynomial you can do

sage: R.<t> = QQ[]
sage: (t^2 + 1).roots(RR)
[]

I.e. there are no roots over RRl. Here's a more interesting example:

sage: (t^7 - 10*t^4 + 1).roots(RR)
[(-0.559900456639459, 1), (0.564904614143836, 1), (2.15107524883421, 1)]

sage: (t^7 - 10*t^4 + 1).roots(RIF)
[(-0.559900456639458794479977438451?, 1),
  (0.56490461414383587778472669435284?, 1),
  (2.151075248834206453076?, 1)]

- Robert

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to