Re: Lists
- To: mathgroup at smc.vnet.net
- Subject: [mg46987] Re: Lists
- From: astanoff at yahoo.fr (astanoff)
- Date: Thu, 18 Mar 2004 04:38:03 -0500 (EST)
- References: <c3bgbb$7pl$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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, Zis is ze way I do : In[1]:= realSolutions[sol_]:=#[[1]]&/@Select[{#,#//N}&/@sol,FreeQ[#[[2]],Complex]&]; Example (InputForms inserted for readability) : In[2]:=sol=Solve[x^3-x+1 == 0]; In[3]:=sol//InputForm Out[3]//InputForm= {{x -> -(2/(3*(9 - Sqrt[69])))^(1/3) - ((9 - Sqrt[69])/2)^(1/3)/3^(2/3)}, {x -> ((1 + I*Sqrt[3])*((9 - Sqrt[69])/2)^(1/3))/(2*3^(2/3)) + (1 - I*Sqrt[3])/(2^(2/3)*(3*(9 - Sqrt[69]))^(1/3))}, {x -> ((1 - I*Sqrt[3])*((9 - Sqrt[69])/2)^(1/3))/(2*3^(2/3)) + (1 + I*Sqrt[3])/(2^(2/3)*(3*(9 - Sqrt[69]))^(1/3))}} In[4]:=realSolutions[sol]//InputForm Out[4]//InputForm= {{x -> -(2/(3*(9 - Sqrt[69])))^(1/3) - ((9 - Sqrt[69])/2)^(1/3)/3^(2/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.