[Date Index]
[Thread Index]
[Author Index]
Re: Lists
*To*: mathgroup at smc.vnet.net
*Subject*: [mg46995] Re: Lists
*From*: astanoff at yahoo.fr (astanoff)
*Date*: Fri, 19 Mar 2004 01:35:48 -0500 (EST)
*References*: <c3bgbb$7pl$1@smc.vnet.net> <c3bqun$f32$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
astanoff wrote:
> Clément wrote:
>> Hello MathGroup,
>> I'm french so i don't speak english very well...
>> I have resolved an equation. So i have a list of solutions.
>> But how can i extract only the reel solutions of this list ?
>> thanks
> --
> Clément,
Something was missing in my solution : to deal with cases such as the
"casus irreducibilis", one has to "Chop" the small imaginary parts :
In[1]:=
realSolutions[sol_]:=#[[1]]&/@
Select[{#,#//N//Chop}&/@sol,FreeQ[#[[2]],Complex]&];
In[2]:=
(* Example (InputForms inserted for readability) : *)
sol=Solve[x^3-10x+1 == 0];
In[3]:=
sol//InputForm
Out[3]//InputForm=
{{x -> ((-9 + I*Sqrt[11919])/2)^(1/3)/3^(2/3) + 10/((3*(-9 +
I*Sqrt[11919]))/2)^(1/3)},
{x -> -((1 + I*Sqrt[3])*((-9 + I*Sqrt[11919])/2)^(1/3))/(2*3^(2/3)) -
(5*(1 - I*Sqrt[3]))/((3*(-9 + I*Sqrt[11919]))/2)^(1/3)},
{x -> -((1 - I*Sqrt[3])*((-9 + I*Sqrt[11919])/2)^(1/3))/(2*3^(2/3)) -
(5*(1 + I*Sqrt[3]))/((3*(-9 + I*Sqrt[11919]))/2)^(1/3)}}
In[4]:=
realSolutions[sol]//InputForm
Out[4]//InputForm=
{{x -> ((-9 + I*Sqrt[11919])/2)^(1/3)/3^(2/3) + 10/((3*(-9 +
I*Sqrt[11919]))/2)^(1/3)},
{x -> -((1 + I*Sqrt[3])*((-9 + I*Sqrt[11919])/2)^(1/3))/(2*3^(2/3)) -
(5*(1 - I*Sqrt[3]))/((3*(-9 + I*Sqrt[11919]))/2)^(1/3)},
{x -> -((1 - I*Sqrt[3])*((-9 + I*Sqrt[11919])/2)^(1/3))/(2*3^(2/3)) -
(5*(1 + I*Sqrt[3]))/((3*(-9 + I*Sqrt[11919]))/2)^(1/3)}}
--
0% de pub! Que du bonheur et des vrais adhérents !
Vous aussi inscrivez-vous sans plus tarder!!
Message posté à partir de http://www.gyptis.org, BBS actif depuis 1995.
Prev by Date:
**Re: Creating a symmetric matrix**
Next by Date:
**Why does Mathematica 5.0 fail where Mathematica 4.1 works ?**
Previous by thread:
**Re: Lists**
Next by thread:
**List of solution**
| |