[Date Index]
[Thread Index]
[Author Index]
Re: Solutions of an equation under complex form
*To*: mathgroup at smc.vnet.net
*Subject*: [mg54544] Re: Solutions of an equation under complex form
*From*: Curt Fischer <tentrillion at gmail.NOSPAM.com>
*Date*: Tue, 22 Feb 2005 04:25:08 -0500 (EST)
*References*: <cvc7un$qqr$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Michaël Monerau wrote:
> Hello,
>
> I'm running into a little problem under Mathematica 5.0 but I'm sure
> people here will just take it as "too easy", but, well :) I just want
> the solutions of the equation :
>
> x^2 + x + 1 == 0
>
> under their complex form.
>
> So, I type :
>
> Solve [x^2 + x + 1 == 0, x]
>
> But I unfortunately get :
> { { {x -> -(-1)^(1/3) }, { x -> (-1)^(2/3) } } }
>
> And I'd prefer to obtain the more "readable" form :
> -1/2 + I*1/2*Sqrt[3], -1/2 - I*1/2*Sqrt[3]
>
> that I would get under another system for instance. What special function
> should I call to get this form under Mathematica ?
The function you want is ComplexExpand. Also, remember that Solve[]
returns replacement rules for the variables solved for. Since equations
in general can have multiple solutions, Solve[] returns a list of
replacement rules. That's why you have all the brackets.
So to isolate the expression that corresponds to the solution, you need
to apply the rules for your solution(s). You can do this one at a time,
like {ComplexExpand[x/.sol[[1]]],ComplexExpand[x/.sol[[2]]]}, or you can
do it all at once by using functional programming as below.
In[1]:=
sol = Solve[x^2 + x + 1 == 0,
x]
Out[1]=
{{x -> -(-1)^(1/3)},
{x -> (-1)^(2/3)}}
In[2]:=
(ComplexExpand[x /.
#1] & ) /@ sol
Out[2]=
{-(1/2) - (I*Sqrt[3])/2,
-(1/2) + (I*Sqrt[3])/2}
--
Curt Fischer
Prev by Date:
**Re: Elegant syntax for multiple conditional assignment?**
Next by Date:
**Re: problems plotting a derivative**
Previous by thread:
**Re: Solutions of an equation under complex form**
Next by thread:
**Re: Solutions of an equation under complex form**
| |