5
 Solve[x^2 + x + 1 == 0, x]

gives the solution:

{{x -> -(-1)^(1/3)}, {x -> (-1)^(2/3)}}

I know these are complex solutions but I'd like to have them in a+bi form. If I do N@Solve...I get the right form but as you can imagine I get numeric approximations.

Any ideas on how to have the solutions be in a+bi form but with exact expressions? I'm pretty sure there's a way to do it by messing with Re[] and Im[] but I'd rather not. Is there a quick way to do this? I am actually surprised the a+bi form isn't the default way to show complex solutions.

chris
  • 22,860
  • 5
  • 60
  • 149
user2686410
  • 347
  • 1
  • 7
  • This really belongs in the docs. They point out the problem, but they do not solve it with ComplexExpand (but with N, which is not equivalent at all). It should also be mentioned in "Background & Context." They use ComplexExpand only once, on a rather esoteric problem. – Michael E2 Mar 19 '21 at 18:49
  • 1
    Related, but closed: https://mathematica.stackexchange.com/questions/141949/power-function-applied-to-complex-number – Michael E2 Mar 19 '21 at 18:53

3 Answers3

9

Try this:

Solve[x^2 + x + 1 == 0, x] // ComplexExpand

(* {{x -> -(1/2) - (I Sqrt[3])/2}, {x -> -(1/2) + (I Sqrt[3])/2}} *)

Have fun!

Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96
  • could use //ExpToTrigas well – Andreas Mar 19 '21 at 09:58
  • @ Andreas In Mma there are often several ways to get the same solution. However, I believe that in the answers here, at StackExchange, it is valuable to demonstrate all of them, even if the question has already been answered. Why don't you write your approach as a regular answer? Somebody will like it more. – Alexei Boulbitch Mar 19 '21 at 16:00
2

Just for completeness: A second way to achieve the desired form is

Solve[x^2 + x + 1 == 0, x] // ExpToTrig
Andreas
  • 3,297
  • 1
  • 5
  • 12
1

For fun.

Solve[x^2 + x + 1 == 0, x] /. x_?NumericQ :> Re@x + I Im@x
AsukaMinato
  • 9,758
  • 1
  • 14
  • 40